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.
Câu 1:
uses crt;
var a:array[1..5]of integer;
max,i:integer;
begin
clrscr;
for i:=1 to 5 do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to 5 do
if max<a[i] then max:=a[i];
writeln(max);
readln;
end.
Câu 2:
uses crt;
var a:array[1..6]of integer;
min,i:integer;
begin
clrscr;
for i:=1 to 6 do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to 6 do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
Câu 1:
uses crt;
var a:array[1..200]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
if a[i] mod 2=0 then t:=t+a[i];
writeln(t);
readln;
end.
Var a:array[1..100] of integer;
i,n:integer;
s:longint;
tbc:real;
Begin
Repeat
Write('n = ');readln(n);
Until (n>0) and (n<=100);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i);readln(a[i]);
s:=s+a[i];
End;
tbc:=s/n;
Write('Trung binh cong la ',tbc:10:2);
Readln
End.
Bài 1
Var a:array:[1..99] of integer;
i,n:integer;
s:longint;
Begin
Repeat
Write('n = ');readln(n);
Until (n > 0) and (n < 100);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
if a[i] mod 2 = 0 then s:=s+a[i];
End;
Write('Cac so vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
write('Tong cac so chan la ',s);
Readln
End.
Bài 2
Var a:array:[1..99] of integer;
i,n:integer;
s:longint;
Begin
Repeat
Write('n = ');readln(n);
Until (n > 0) and (n < 100);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
if a[i] mod 2 <> 0 then s:=s+a[i];
End;
Write('Cac so vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
write('Tong cac so le la ',s);
Readln
End.
Var a:array[1..30] of integer;
i,n,d,max:integer;
Begin
Write('Nhap so luong phan tu cua mang ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
max:=a[1];
For i:=2 to n do
Begin
If a[i] > max then
Begin
max:=a[i];
d:=i;
End;
End;
Write('Phan tu lon nhat la ',max,' o vi tri ',d);
Readln;
End.
Var a:array[1..30] of integer;
i,n,d,max:integer;
Begin
Write('Nhap so luong phan tu cua mang ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
max:=a[1];
For i:=2 to n do
Begin
If a[i] > max then
Begin
max:=a[i];
d:=i;
End;
End;
Write('Phan tu lon nhat la ',max,' o vi tri ',d);
Readln;
End.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
tb:real;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t/n:4:2);
tb:=t/n;
for i:=1 to n do
if a[i]<tb then write(a[i]:4);
readln;
end.
program XuatSoChan;
uses crt;
const
Max_N = 20;
type
MangSoNguyen = array [1..Max_N] of integer;
var
A: MangSoNguyen;
i, n: integer;
begin
clrscr;
write('Nhap so luong phan tu cua mang: ');
readln(n);
writeln('Nhap cac phan tu vao mang:');
for i := 1 to n do
begin
write('A[', i, ']: ');
readln(A[i]);
end;
writeln('Cac so chan trong mang la:');
for i := 1 to n do
begin
if A[i] mod 2 = 0 then
writeln(A[i]);
end;
readln;
end.