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;
}
uses crt;
var a,b,c:array[1..250]of integer; i,n,dem,dem1,sd,vtd,sa,vta,sdcc,sacc,vtd1,vtc1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if a[i]>0 then
begin
dem:=dem+1;
b[dem]:=a[i];
end;
if a[i]<0 then
begin
inc(dem1);
c[dem1]:=a[i];
end;
end;
writeln('So duong dau tien trong day la: ',b[1]);
sd:=b[1];
vtd:=n;
for i:=n downto 1 do
if sd=a[i] then
begin
if vtd>i then vtd:=i;
end;
writeln('Chi so cua no la: ',vtd);
writeln('So am dau tien trong day la: ',c[1]);
sa:=c[1];
vta:=n;
for i:=n downto 1 do
if sa=a[i] then
begin
if vta>i then vta:=i;
end;
writeln('Chi so cua no la: ',vta);
writeln('So duong cuoi cung trong day la: ',b[dem]); sdcc:=b[dem];
vtd1:=1;
for i:=1 to n do
if sdcc=a[i] then
begin
if vtd1<i then vtd1:=i;
end;
writeln('Chi so cua no la: ',vtd1);
writeln('So am cuoi cung trong day la: ',c[dem]); sacc:=c[dem];
vtc1:=1;
for i:=1 to n do
if sacc=a[i] then
begin
if vtc1<i then vtc1:=i;
end;
writeln('Chi so cua no la: ',vtc1);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,t1,t2: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];
t1:=0;
t2:=0;
for i:=1 to n do
begin
if a[i]>0 then t1:=t1+a[i];
if a[i]<0 then t2:=t2+a[i];
end;
writeln('Tong cac phan tu la: ',t);
writeln('Tong cac so duong la: ',t1);
writeln('Tong cac so am la: ',t2);
writeln('Trung binh cong cua day la: ',t/n:4:2);
readln;
end.
1:
#include <bits/stdc++.h>
using namespace std;
long long t1,t2,i,n,x;
int main()
{
cin>>n;
t1=0;
t2=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x>0) t1=t1+x;
else t2=t2+x;
}
cout<<t1<<" "<<t2;
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.
#include <bits/stdc++.h>
using namespace std;
double a[100],t1,t2,k;
int i,n,dem;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
cin>>k;
dem=0;
for (i=1; i<=n; i++) if (a[i]==k) dem++;
t1=0;
t2=0;
for (i=1; i<=n; i++)
{
if (a[i]>0) t1+=a[i];
else t2+=a[i];
}
cout<<dem<<endll;
cout<<t1<<" "<<t2;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,dem,s,s1,vt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
s:=1;
for i:=1 to n do
if a[i]=3 then
begin
inc(dem);
s:=s*a[i];
end;
writeln('So phan tu bang 3 la: ',dem);
writeln('Tich cua chung la: ',s);
for i:=n downto 1 do
if a[i]<0 then
begin
vt:=i;
break;
end;
if vt=0 then writeln('Trong day khong co so am')
else writeln('So am cuoi cung la: ',a[vt]);
s1:=1;
for i:=1 to n do
if (a[i] mod 3=0) or (a[i] mod 4=0) then s1:=s1*a[i];
writeln('Tich cac phan tu chia het cho 3 hoac 4 la: ',s1);
writeln('Cac so nguyen la: ');
for i:=1 to n 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.