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,dem1,dem2,t1,t2;
int main()
{
cin>>n;
dem1=0;
dem2=0;
t1=0;
t2=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x>0)
{
dem1++;
t1+=x;
}
if (x<0)
{
dem2++;
t2+=x;
}
}
cout<<dem1<<" "<<dem2<<endl;
cout<<t1<<" "<<t2;
return 0;
}
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if ((x<0) and (x%2!=0)) t=t+x;
}
cout<<t;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,a[10000];
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x<0) t+=x;
}
cout<<t;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,dem,t,j,t1;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
for (i=1; i<=n; i++)
{
t=0;
for (j=1; j<=a[i]-1; j++)
if (a[i]%j==0) t+=j;
if (t==a[i]) dem++;
}
cout<<dem<<endl;
t1=0;
for (i=1; i<=n; i++)
if (a[i]%2==0) t1+=a[i];
cout<<t1;
return 0;
}
uses crt;
var a:array[1..6]of integer;
i,dem,t:integer;
begin
clrscr;
for i:=1 to 6 do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to 6 do
if a[i]>0 then
begin
inc(dem);
t:=t+a[i];
end;
writeln('So phan tu duong la: ',dem);
writeln('Tong cac phan tu duong la: ',t);
readln;
end.
uses crt;
var a:array[1..100]of integer;
n,i,t,nn,kt:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=1;
for i:=1 to n do
if a[i] mod 3=0 then t:=t*a[i];
writeln(t);
kt:=0;
nn:=32567;
for i:=1 to n do
if a[i] mod 3=0 then
begin
if nn>a[i] then nn:=a[i];
kt:=1;
end;
if kt=0 then writeln('Khong co so chia het cho 3')
else writeln('So nho nhat chia het cho 3 la: ',nn);
for i:=1 to n do
if nn=a[i] then write(i:4);
writeln;
for i:=n downto 1 do
write(a[i]:4);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem1,dem2,t1,t2,sa,sd,vt1,vt2:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
dem1:=0;
t1:=0;
dem2:=0;
t2:=0;
for i:=1 to n do
begin
if a[i]>0 then begin inc(dem1); t1:=t1+a[i]; end;
if a[i]<0 then begin inc(dem2); t2:=t2+a[i]; end;
end;
writeln(dem1);
writeln(dem2);
writeln(t1);
writeln(t2);
for i:=1 to n do
if a[i]>0 then
begin
sd:=a[i];
vt1:=i;
break;
end;
if (dem1=0) then writeln('Khong co so duong trong day')
else writeln('So duong dau tien la: ',sd,' vi tri la: ',vt1);
for i:=1 to n do
if a[i]<0 then
begin
sa:=a[i];
vt2:=i;
break;
end;
if (dem2=0) then writeln('Khong co so am trong day')
else writeln('So am dau tien la: ',sa,' vi tri la: ',vt2);
readln;
end.