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.
program max_min;
uses crt;
var i,n,max,min: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;
writeln('day vua nhap la:');
for i:=1 to n do
write(a[i]:3);
writeln;
max:=a[1];min:=a[1];
for i:=1 to n do
begin
if a[i]>max then max:=a[i];
if a[i]<min then min:=a[i];
end;
writeln('gia tri lon nhat: ',max,' gia tri nho nhat: ',min);
readln;
end.
uses crt;
var a:array[1..1000000] of longint;
n,i,max,min:longint;
begin
clrscr;
write('Nhap so luong phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
write('Day so vua nhap: ');
for i:=1 to n do write(a[i],' '); writeln;
max:=a[1];min:=a[1];
for i:=2 to n do
begin
if a[i]>max then max:=a[i];
if a[i]<min then min:=a[i];
end;
writeln('GTLN: ',max);
writeln('GTNN: ',min);
readln;
end.
Program HOC24;
var i,n: integer;
a: array[1..32000] of integer;
begin
write('Nhap N:' ); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap vua nhap la: ');
for i:=1 to n do write(a[i],' ');
readln
end.
uses crt;
var a:array[1..1000000] of longint;
n,i:longint;
begin
clrscr;
write('Nhap so luong phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
write('Day so vua nhap: ');
for i:=1 to n do write(a[i],' ');
readln;
end.
Var a:array[1..100] of integer;
i,n:integer;
s:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
s:=s+a[i];
End;
Write('Cac phan tu vua nhap la ');
For i:=1 to n do
Write(a[i]:8);
Writeln;
Write('Tong cua chung la ',s);
Readln
End.
Var a:array:[1..1000] of integer;
i,n,max,t,d:integer;
s:longint;
tb:real;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
s:=s+a[i];
End;
tb:=s/n;
Write('Cac so vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
writeln('Trung binh cong cua day la ',tb:10:2);
Write('Cac so la boi cua 3 la ');
For i:=1 to n do
if a[i] mod 3 = 0 then write(a[i]:8);
writeln;
write('Cac so le la boi cua 5 la ');
for i:=1 to n do
if (a[i] mod 2 <> 0) and (a[i] mod 5 = 0) then
write(a[i]:8);
Writeln;
max:=a[1];
for i:=1 to n do
if a[i] > max then
begin
max:=a[i];
d:=i;
End;
Writeln('So lon nhat la ',max);
t:=a[1];
a[1]:=max;
a[d]:=t;
Write('Day sau khi dem so lon nhat ra truoc ');
For i:=1 to n do
write(a[i]:8)
writeln;
tb:=(a[8] + a[10])/2);
Write(Trung binh cong cua so thu 8 va thu 10 la ',tb:10:2);
Readln
End.
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
readln;
end.
uses crt;
var a:array[1..1000000] of longint;
n,i:longint;
begin
clrscr;
write('Nhap so luong phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
write('Cac so chan: ');
for i:=1 to n do if a[i] mod 2=0 then write(a[i],' ');
readln;
end.
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(t);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,x,dem,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap x='); readln(x);
kt:=0;
dem:=0;
for i:=1 to n do
if a[i]=x then
begin
kt:=1;
write(i:4);
inc(dem);
end;
if kt=0 then writeln('Khong co ',x,' trong day');
writeln(x,' xuat hien ',dem,' lan trong day');
readln;
end.
Bài 1
Var s,i:integer;
tb:real;
Begin
Write('Nhap n = ');readln(n);
i:=1;
s:=0;
While i<=n do
Begin
s:=s+i;
i:=i+1;
End;
tb:=s/n;
Writeln('Tong la ',s);
Write('Trung binh la ',tb:10:2);
Readln;
End.
Bài 2
Var i,n,souoc:integer;
Begin
Write('Nhap n = ');readln(n);
i:=1;
While i <= n do
Begin
i:=i + 1;
If n mod i = 0 then souoc:=souoc + 1;
End;
If souoc = 1 then write(n,' la so nguyen to')
Else write(n,' khong la so nguyen to');
Readln;
End.
program max_min;
uses crt;
var i,n: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;
writeln('day vua nhap la:');
for i:=1 to n do
write(a[i]:3);
readln;
end.