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.
#include <bits/stdc++.h>
using namespace std;
long long a[100],i,n,t,nn;
int main()
{
cin>>n;
for (i=1;i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++) if (a[i]%2==0) t+=a[i];
nn=a[1];
for (i=1; i<=n; i++)
nn=min(nn,a[i]);
cout<<t<<endl;
cout<<nn<<endl;
cout<<a[1]+a[n];
return 0;
}
uses crt;
var a:array[1..50]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
if a[i] mod 2<>0 then write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if (100<a[i]) and (a[i]<15000) then t:=t+a[i];
writeln(t);
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]);
for i:=1 to n do write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if a[i]>0 then t:=t+a[i];
writeln(t);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,max,min:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('A[',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('Gia tri lon nhat la: ',max);
writeln('Gia tri nho nhat la: ',min);
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.
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.
a) var a:array[1..1000] of integer;
i,k:integer;
p:longint;
begin
write('k = ');readln(k);
p:=1;
for i:=1 to k do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
if a[i]<30 then p:=p*a[i];
end;
write('Tich la ',p);
readln
end.
b)
var a:array[1..1000] of integer;
i,k:integer;
s:longint;
begin
write('k = ');readln(k);
for i:=1 to k do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
if a[i]<100 then s:=s+a[i];
end;
write('Tong la ',s);
readln
end.
BT1:
Uses crt;
var i,n: integer;
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do
read(a[i]); readln;
writeln(a[i]:3);
readln;
end.
BT2:
Uses crt;
var i,n,k: integer;
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do
read(a[i]); readln;
for i:=1 to n do begin
if(a[i] mod 2=0) then k:=k+a[i];
end;
writeln(k);
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;
nn:=a[1];
ln:=a[1];
for i:=1 to n do
begin
t:=t+a[i];
if nn>a[i] then nn:=a[i];
if ln<a[i] then ln:=a[i];
end;
writeln(t);
writeln(ln);
writeln(nn);
writeln(t/n:4:2);
readln;
end.
Program mang1chieu;
uses crt;
var a:array[1..100] of integer; s,dem,i,n,min,max :integer;
begin
s:=0; dem:=0;
writeln('nhap do dai day');readln(n);
for i:=1 to n do begin writeln('a[',i,']');readln(a[i]); s:=s+a[i]; if a[i] mod 3 =0 then dem:=dem +1;end;
for i:=1 to n do if a[i] mod 2 = 0 then write('cac phan tu chan',a[i],' ');
write('tong cac phan tu da nhap vao la',s);
min :=a[1]; max:=a[1];
for i:= 2 to n do if a[i] <min then min:=a[i];
for i:= 2 to n do if a[i]> max then max:=a[i];
write('so lon nhat trong day la',max); write('so nho nhat trong day la',min);
write('so phan tu chia het cho 3 la:',dem);