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[1000],n,i,dem1,dem2;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem1=0;
dem2=0;
for (i=1; i<=n; i++)
{
if (a[i]%2==0) dem1++;
else dem2++;
}
cout<<dem1<<" "<<dem2;
return 0;
}
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.
Program HOC24;
var d,i,n: integer;
a: array[1..32000] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('Cac phan tu cua mang vua nhap la: ');
for i:=1 to n do write(a[i],' ');
writeln;
d:=0;
for i:=1 to n do if 10 mod a[i]=0 then d:=d+1;
writeln('Co ',d,' phan tu co gia tri la uoc cua 10');
write('Cac phan tu o vi tri chan la: ');
for i:=1 to n do if i mod 2=0 then write(a[i],' ');
writeln;
write('Cac phan tu o vi tri le la: ');
for i:=1 to n do if i mod 2=1 then write(a[i],' ');
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.
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.
Program HOC24;
var a: array[1..50] of integer;
i,n: byte;
t: longint;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Cac phan tu chan trong mang la: ');
for i:=1 to n do
if a[i] mod 2=0 then
begin
write(a[i],' ');
t:=t+a[i];
end;
writeln;
write('Tong cac phan tu chan trong day la: ',t);
readln
end.
Program HOC24;
var i,n: byte;
t: longint:
a: array[1..50] of integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do begin write('A[',i,']='); readln(a[i]); end;
t:=0;
write('Cac phan tu chan co trong mang la: ');
for i:=1 to n do
if a[i] mod 2=0 then
begin
write(a[i],' ');
t:=t+a[i];
end;
writeln;
write('Tong cac phan tu chan do la: ',t);
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long d[60],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>d[i];
for (i=1; i<=n; i++) cout<<d[i]<<" ";
return 0;
}