Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
var i,n,tb :integer;
begin
readln(n);
tb:=0;
for i:=1 to n do tb:=tb+1;
writeln(tb);
end.
program CTTTB;
uses crt;
var TB,x:real; n,y: integer;
begin
Write('Hay nhap so so thuc ban can tinh TB'); Readln(n);
for y:=1 to n do
begin Write('Nhap so thu',y);Readln(x);
TB:=TB+x;
end;
TB:=TB/n;
Writeln('Trung binh cong cua',n,' so nhap vao tu ban phim la',TB);
Readln;
End.
bài này dễ ẹt à
uses crt;
var a:array[1..100]of integer;
i,n,ln:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{--------------------xuat-day---------------------}
for i:=1 to n do
write(a[i]:4);
{-------------------xu-ly-------------------------}
writeln;
ln:=a[1];
for i:=1 to n do
if ln<a[i] then ln:=a[i];
writeln('so lon nhat la: ',ln);
readln;
end.
Program bai1;
uses crt;
var a: array [1..100] of integer;
i,n,min,s: integer;
begin
clrscr;
write('nhap n ='); readln(n);
for i:= 1 to n do
begin
write('nhap a[',i,'] ='); readln(a[i]);
end;
min:=a[1];
s:=0;
for i := 1 to n do
s:=s+a[i];
write('tong cac day so trong mang =',s :4);
writeln;
for i:= 1 to n do
if min > a[i] then min:=a[i];
write('so nho nhat trong day la :' ,a[i]);
readln;
end.
Program So_nho_nhat;
uses crt;
Var i,n:Byte; so,Min:Integer;
Begin
clrscr;
Writeln('TIM SO LON NHAT TRONG N SO NGUYEN');
Writeln('---------------------------------'); Write('Cho biet so phan tu nhap N= '); Readln(n); i:=1;
Write('So thu ',i,' = '); Readln(so); Min:=so; For i:=2 To N Do Begin
Write('So thu ',i,' = '); Readln(so);
If Min < so Then Min:=so;
End;
Writeln;
Writeln('+So lon nhat trong ',n,' so vua nhap la so: ',Min);
Writeln(' Bam phim de ket thuc');
Readln;
End.
var i,n,s:integer;
begin
readln(n);
s:=0;
for i:=1 to n do s:=s+1/i;
writeln(s:3:0);
end.
Uses Crt;
Var i,n,m:integer;
a:array[1..100] of integer;
Begin
Clrscr;
Write('Nhap n = ');
Readln(n);
For i:=1 to n do
Begin
Write('A[',i,'] = ');Readln(a[i]);
End;
m:=A[1];
For i:=2 to n do If A[i]<m then m:=A[i];
Writeln(m);
Readln;
End.
viết lại nha
Var i,n,m:integer;
a:array[1..100] of integer;
Begin
Write('Nhap n = ');
Readln(n);
For i:=1 to n do
Begin
Write('A[',i,'] = ');
Readln(a[i]);
End;
m:=A[1];
For i:=2 to n do If A[i]>m then m:=A[i];
Writeln(' So lon nhat trong day la: ',m);
Readln;
End.
bài này mới đúng nhe bạn:
program sntmax;
uses crt;
var n,i:word;
a:array[1..10000] of longint;
max:longint;
f:text;
function ktsnt(b:longint):boolean;
var dem,j:byte;
begin
dem:=0;
for j:=1 to b do
if b mod j =0 then dem:=dem+1;
ktsnt:=dem=2;
end;
begin
clrscr;
readln(n);
while (n<1) or (n>10000) do readln(n);
for i:=1 to n do read(a[i]);
readln;
assign(f,'D:\NTOMAX.OUT');
rewrite(f);
max:=0;
for i:=1 to n do
if ktsnt(a[i])=true then
begin
max:=a[i];
break;
end;
if max=0 then write(f,'khong co so nguyen to trong mang')
else
begin
for i:=1 to n do
if (ktsnt(a[i])=true) and (a[i]>max) then max:=a[i];
write(f,max);
end;
close(f);
readln;
end.
thi r