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 x,n,i,t,dem;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0 && x>10) t+=x;
if (x%2!=0 || x<100) dem++;
}
cout<<t<<" "<<dem;
return 0;
}
uses crt;
var a:array[1..200]of integer;
n,i,k,t,t1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
t:=0;
for i:=1 to n do
if a[i] mod 2<>0 then t:=t+a[i];
t1:=0;
for i:=1 to n do
if a[i] mod k=0 then t1:=t1+a[i];
writeln('Tong cac phan tu le la: ',t);
writeln('Tong cac phan tu la boi cua ',k,' la: ',t1);
readln;
end.
uses crt;
var a:array[1..100]of integer;
n,i,k,dem,dem1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem);
if a[i] mod k=0 then inc(dem1);
end;
writeln('So phan tu chan la: ',dem);
writeln('So phan tu chia het cho ',k,' la: ',dem1);
readln;
end.
var n,i,dem,t:integer;
a:array[1..50] of integer;
begin
dem:=0;
t:=0;
read(n);
for i:=1 to n do
read(a[i]);
for i:=n downto 1 do
write(a[i]);
writeln;
for i:=1 to n do
if (a[i] mod 2 = 0) then dem:=dem+1;
if a[i]<a[i-1] then t:=t+1;
writeln(dem);
if t=0 then write('Co lap thanh cap so +')
else write('Ko the lap thanh cap so +');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,nn,t1,t2,dem1,dem2,a[1000];
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
nn=a[1];
for (i=1; i<=n; i++) nn=min(nn,a[i]);
cout<<nn<<endl;
for (i=1; i<=n;i++)
if (a[i]%2==0) cout<<a[i]<<" ";
cout<<endl;
for (i=1; i<=n;i++)
if (a[i]%2!=0) cout<<a[i]<<" ";
cout<<endl;
t1=0;
t2=0;
dem1=0;
dem2=0;
for (i=1; i<=n; i++)
{
if (a[i]%2==0)
{
t1+=a[i];
dem1++;
}
else
{
t2+=a[i];
dem2++;
}
}
cout<<t1<<" "<<dem1<<endl;
cout<<t2<<" "<<dem2;
return 0;
}
tham khảo
#include <bits/stdc++.h>
using namespace std;
long long n,i,nn,t1,t2,dem1,dem2,a[1000];
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
nn=a[1];
for (i=1; i<=n; i++) nn=min(nn,a[i]);
cout<<nn<<endl;
for (i=1; i<=n;i++)
if (a[i]%2==0) cout<<a[i]<<" ";
cout<<endl;
for (i=1; i<=n;i++)
if (a[i]%2!=0) cout<<a[i]<<" ";
cout<<endl;
t1=0;
t2=0;
dem1=0;
dem2=0;
for (i=1; i<=n; i++)
{
if (a[i]%2==0)
{
t1+=a[i];
dem1++;
}
else
{
t2+=a[i];
dem2++;
}
}
cout<<t1<<" "<<dem1<<endl;
cout<<t2<<" "<<dem2;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,min,t1,t2,dem1,dem2:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
min:=a[1];
for i:=1 to n do if min>a[i] then min:=a[i];
writeln(min);
writeln('Cac so chan la: ');
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
writeln;
writeln('Cac so le la: ');
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
writeln;
t1:=0;
t2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then t1:=t1+a[i]
else t2:=t2+a[i];
end;
writeln(t1,' ',t2);
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then dem1:=dem1+1
else dem2:=dem2+1;
end;
writeln(dem1,' ',dem2);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[10000],i,n,t1,t2,dem1,dem2;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
dem1=0;
dem2=0;
t1=0;
t2=0;
for (i=1; i<=n; i++)
{
if (a[i]>0)
{
dem1++;
t1+=a[i];
}
if (a[i]<0)
{
dem2++;
t2+=a[i];
}
}
long long t3=0;
for (i=1; i<=n; i++)
if (i%2==1) t3+=a[i];
long long t4=0;
for (i=1; i<=n; i++)
if (i%2==1 && a[i]%2==0) t4+=a[i];
cout<<t1<<" "<<t2<<endl;
cout<<dem1<<" "<<dem2<<endl;
cout<<t3<<endl;
cout<<t4<<endl;
for (i=1; i<=n; i++)
if (a[i]%3==0) cout<<a[i]<<" ";
return 0;
}
Program HOC24;
var d,i,n: integer;
a: array[1..100] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap A[',i,']='); readln(a[i]);
end;
d:=0;
for i:=1 to n do d:=d+1;
write('So luong cac phan tu trong mang la: ',d);
readln
end.
* Thực chất số lượng phần tử trong mảng là N ban đầu nhập rồi, bạn kiểm tra lại xem đề thiếu không nhé
uses crt;
var a:array[1..10]of integer;
i,n,dem,t,dem1,t1:integer;
begin
clrscr;
write('nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
dem:=dem+1;
t:=t+a[i];
end;
writeln('So so chan trong mang la: ',dem);
writeln('Tong cac so chan trong mang la: ',t);
dem1:=0;
t1:=0;
for i:=1 to n do
if a[i] mod 2<>0 then
begin
inc(dem1);
t1:=t1+a[i];
end;
writeln('So so le trong mang la: ',dem1);
writeln('Tong cac so le trong mang la: ',t1);
readln;
end.
Cảm ơn ạ!