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 max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+a[i];
end;
max:=a[1];
min:=a[1];
for i:=1 to n do begin
if(max<a[i]) then max:=a[i];
if(min>a[i]) then min:=a[i];
end;
Writeln('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
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.
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.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,ln,nn,t;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
t=0;
for (i=1; i<=n; i++) t+=a[i];
ln=a[1];
nn=a[1];
for (i=2; i<=n; i++)
{
ln=max(ln,a[i]);
nn=min(nn,a[i]);
}
cout<<t<<endl;
cout<<ln<<" "<<nn;
return 0;
}
Var a:array[1..200] of integer;
i,n,s,max,min:integer;
Begin
Write('Nhap so luong phan tu n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
s:=a[1];
max:=a[1];
min:=a[1];
For i:=2 to n do
Begin
s:=s+a[i];
If a[i] > max then max:=a[i];
If a[i] < min then min:=a[i];
End;
Writeln('Tong la ',s);
Writeln('So lon nhat la ',max);
Write('So nho nhat la ',min);
Readln;
End.
uses crt;
var a: array[1..100] of longint;
i,n,max,min: longint;
begin
clrscr;
readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': ');
readln(a[i]);
end;
max:=a[1]; min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('So lon nhat trong mang la: ',max);
write('So nho nhat trong mang la: ',min);
readln
end.
uses crt;
var a:array[1..20]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;
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day la: ',t);
for i:=1 to n do
if a[i]>50 then write(a[i]:4);
writeln;
for i:=1 to n do
if a[i]<30 then write(a[i]:4);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,ln,nn:integer;
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);
ln:=a[1];
nn:=a[1];
for i:=1 to n do
begin
if ln<a[i] then ln:=a[i];
if nn>a[i] then nn:=a[i];
end;
writeln(ln);
writeln(nn);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do
if a[i]>0 then t:=t+a[i];
writeln(t);
readln;
end.
var a:[array] of integer;
i,n,max,min,s:integer;
begin
write('Nhap so luong so n = ');readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
end;
max:=a[1];
min:=a[1];
s:=0;
for i:=1 to n do
begin
if a[i] > max then max:=a[i];
if a[i] < min then min:=a[i];
s:=s+a[i];
end;
writeln('So lon nhat la ',max);
writeln('So nho nhat la ',min);
writeln('Tong cac phan tu trong day la ',s);
writeln('Cac so chia het cho 2 la: ');
for i:=1 to n do
if a[i] mod 2 = 0 then write(a[i],' ');
readln;
end.
Uses crt;
var max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+a[i];
end;
max:=a[1];
min:=a[1];
for i:=1 to n do begin
if(max<a[i]) then max:=a[i];
if(min>a[i]) then min:=a[i];
end;
Writeln('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
readln;
end.