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.
2:
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) if (a[i]%2==0) cout<<a[i]<<" ";
return 0;
}
program timso;
var
n, i, max: integer;
begin
write('Nhap so luong so nguyen: ');
readln(n);
max := -maxint;
for i := 1 to n do
begin
write('Nhap so thu ', i, ': ');
readln(num);
if num > max then
max := num;
end;
writeln('So lon nhat la: ', max);
end.
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.
uses crt;
var n,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
if n mod i=0 then
begin
write(i:4);
t:=t+i;
end;
writeln;
writeln('Tong cac uoc cua ',n,' la: ',t);
readln;
end.
program chuong_trinh;
uses crt;
var n,i,tong:integer;
a: array[1..1000] of integer;
begin
clrscr;
writeln('Nhap so phan tu cua day: ');readln(n);
writeln('Nhap ',n,' phan tu cua day: ');
for i:= 1 to n do readln(a[i]);
tong:=0;
for i:= 1 to n do if a[i] mod 2 = 1 then tong:=tong+a[i];
writeln('Tong cac so le trong mang la: ',tong);
readln
end.
Program Đổi_Tiền;
var
loai5000,loai2000,loai1000,m,n: integer;
write('nhap so tien can doi :'); readln(n);
M:=n;
loai5000:= n div 5000; n:=n-loai5000*5000;
if n<>0 then
begin
loai2000 :=n div 2000; n:=n-loai2000*2000;
if n<>0 then
begin
loai1000:=n div 1000 ; n:=n-loai1000*1000;
end;
writeln(M , 'doi duoc thanh :' ,loai5000,' to 5000,' ,loai2000,' to 2000 ,' ,loai1000,' to 1000 ,');
readln;
end.
program tinhtongtubanphim;
var i,s : real; kt:boolean;
begin
s:=0;
kt:=true;
while kt=true do
begin
write("nhap so tu ban phim: ");
readln(i);
s:=s+i;
if i:=0 then kt:=false;
end;
writeln('Tong = ',s);
readln;
end.