Những câu hỏi liên quan
Tiên trần
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 2 2022 lúc 23:28

#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ình luận (0)
Sulann
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 12 2020 lúc 22:51

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.

Bình luận (0)
Anh Lê duy
Xem chi tiết
Trâm Đỗ
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 12 2021 lúc 23:07

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;

}

Bình luận (0)
Vũ Tú
Xem chi tiết
Hoan Lý
Xem chi tiết
Kiều Vũ Linh
10 tháng 5 2023 lúc 4:33

Câu 1:

var i,n:integer;

s:longint;

begin

Write('n = ');readln(n)

for i:=1 to n do

s:=s+2*i+1;

write('tong la: ',s);

readln

end.

Bình luận (0)
Kiều Vũ Linh
10 tháng 5 2023 lúc 4:36

Câu 2

Bài 5:

Var b:array:[1..1000] of integer;

i,n,max:integer;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap so thu ',i,' = ');readln(b[i]);

End;

Write('Cac phan tu am la: ');

For i:=1 to n dko

if b[i]<0 then write(b[i]:8);

writeln;

max:=b[1];

For i:=2 to n do

If b[i] > max then max:=b[i];

write('So lon nhat la ',max);

Readln

End.

Bình luận (0)
NTTN
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 3 2022 lúc 20:27

#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;

}

Bình luận (0)
anhle
Xem chi tiết
Danh Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 7:23

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;

}

Bình luận (0)