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.
uses crt;
var a:array[1..100]of integer;
i,n,t1,t2,dem1,dem2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Day so vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t1:=0;
dem1:=0;
t2:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then
begin
t1:=t1+a[i];
inc(dem1);
end
else begin
t2:=t2+a[i];
inc(dem2);
end;
end;
writeln('Trung binh cac so chan la: ',t1/dem1:4:2);
writeln('Trung binh cac so le la: ',t2/dem2:4:2);
readln;
end.
program TongChanLe;
var
n,i, chans, les: integer; a: array[1..100] of integer;
begin
chans := 0;
les := 0;
write('Nhap n: ');
readln(n);
for i:=1 to n do
begin
write('Nhap so thu ', i, ': ');
readln(a[i]);
if a[i] mod 2 = 0 then
chans := chans + a[i]
else
les := les + a[i];
end;
writeln('Tong cac so chan la: ', chans);
writeln('Tong cac so le la: ', les);
readln;
end.
bạn tham khảo
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.
uses crt;
var a: array[1..100] of integer;
i: longint;
begin
clrscr;
for i:=1 to 20 do readln(a[i]);
writeln('day vua nhap la:');
for i:=1 to 20 do write(a[i],' ');
readln
end.
uses crt;
var a:array[1..20]of integer;
i,n:integer;
begin
clrscr;
n:=20;
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
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.
Bài 1:
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.
Bài 2:
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.
Var a:array[1..1000] of integer;
i,n:integer;
sc,sl:longint;
Begin
Write('Nhap so luong so cua day ');readln(n);
For i:=1 to n do
Begin
Write(a,'[',i,'] = ');readln(a[i]);
End;
Write('Tong cac so chan la ');
For i:=1 to n do
If a[i] mod 2 = 0 then sc:=sc+a[i];
Writeln(sc);
Write('Tong cac so le la ');
For i:=1 to n do
If a[i] mod 2 <> 0 then sl:=sl+a[i];
Write(sl);
Readln
End.
Bài 5:
Var a:array:[1..1000] of integer;
i,n,max:integer;
sc, sl:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');rreadlna[i]);
If a[i] mod 2 = 0 then sc:=sc+b[i];
If a[i] mod 2 <> 0 then sl:=sl+a[i];
End;
max:=a[1];
For i:=2 to n do
If a[i] > max then max:=a[i];
Writeln('Tong cac so chan la ',sc);
Writeln('Tong cac so le la ',sl);
write('So lon nhat la ',max);
Readln
End.
1:
#include <bits/stdc++.h>
using namespace std;
long long n=10, a[10],i,nn;
int main()
{
for (i=1; i<=n; i++) cin>>a[i];
nn=a[1];
for (i=2; i<=n; i++) nn=min(nn,a[i]);
cout<<nn;
return 0;
}