Những câu hỏi liên quan
Hải Phong
Xem chi tiết
Hải Phong
10 tháng 12 2021 lúc 11:13

huhu giúp với ạ cần gấp lắm

Nguyễn Lê Phước Thịnh
10 tháng 12 2021 lúc 23:14

1:

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

t=t+x;

}

cout<<t;

return 0;

}

33. Phan Dương Sinh 10A8
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 12 2021 lúc 23:56

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

t=t+x;

}

cout<<t;

return 0;

}

Thư Phan
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 10 2021 lúc 0:10

#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%2!=0) t=t+x;

}

cout<<t;

return 0;

}

Nga Nguyễn
Xem chi tiết
Hoàng Lê Bảo Ngọc
27 tháng 12 2016 lúc 17:51

Bài 1.

Bước 1. Nhập N và dãy số \(a_1,a_2,...,a_N\)

Bước 2. \(i\leftarrow1\), \(S\leftarrow0\)

Bước 3. \(i\leftarrow i+1\)

Bước 4. 4.1 Nếu \(i>N\) thì kết thúc thuật toán và đưa ra kết quả.

4.2 \(a_i\ge0\) thì quay lại bước 3

4.3 \(S\leftarrow S+a_i\) rồi quay lại bước 3

Kiều Giàng
12 tháng 12 2021 lúc 9:31

Viết thuật toán tính tổng các phần tử bằng 0

Hoàng Hải Yến
Xem chi tiết
Nguyễn Thiện Minh
23 tháng 11 2016 lúc 15:48

uses crt;

var a: array [1..100] of integer;

n, i, tsc, tsl: integer

begin

clrscr;

write('So phan tu cua mang la: '); readln(n);

while n<1 do begin

write('So phan tu chi tu 2 tro len, ban da nhap sai, nhap lai: '); readln(n);

end;

for i:=1 to n do begin

write('So thu ',i,' la: '); readln(a[i]);

end;

tsc:=0;

tsl:=0;

for i:=1 to n do

if a[i] mod 2 =0 then tsc:=tsc+a[i]

else tsl:=tsl+a[i];

writeln('tong cac so chan la: ',tsc);

write('tong so cac so le la: ',tsl);

readln;

end.

duong nguyenvan
20 tháng 12 2017 lúc 16:26

Program bai1;

uses crt;

var i,n,s,s1: integer;

a:array[1..100] of integer;

begin

clrscr;

write('nhap n =');readln(n);

for i:=1 to n do

begin

write('nhap a[',i,'] ='); readln(a[i]);

end;

for i:= 1 to n do

if a[i] mod 2 = 0 then s:=s+a[i];

writeln('tong cac so duong = ' ,s);

for i:= 1 to n do

if a[i] mod 2 <> 0 then s1:=s1+a[i];

writeln('tong cac so le =' ,s1);

readln;

end.

Hoàng Hải Yến
Xem chi tiết
Lieu Loo
29 tháng 12 2017 lúc 13:24

for i:=1 to n do

if a[i] mod 2=0 then s:=s+a[i] else ss:=ss+a[i];

writeln(' a)', s);

write(' b),ss);

Lê Thị Bích Ngân
Xem chi tiết
Sarah Lilia
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 2 2021 lúc 20:53

uses crt;

var a:array[1..100]of integer;

i,n,dem,dem1,dem2,t:integer;

s:real;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

begin

repeat

write('A[',i,']='); readln(a[i]);

until a[i]>0;

end;

for i:=1 to n do 

  write(a[i]:4);

writeln;

dem:=0;

for i:=1 to n do

  if a[i]>10 then inc(dem);

writeln('So phan tu lon hon 10 la: ',dem);

dem1:=0;

dem2:=0;

for i:=1 to n do 

begin

if a[i] mod 2=0 then inc(dem1)

else inc(dem2);

end;

writeln('So luong so chan la: ',dem1);

writeln('So luong so le la: ',dem2);

t:=0;

s:=1;

for i:=1 to n do 

  begin

if (i mod 2=0) and (a[i] mod 2<>1) then t:=t+a[i];

if (i mod 2=1) and (a[i] mod 2=0) then s:=s*a[i];

end;

writeln('Tong cac so o vi tri chan co gia tri le la: ',t);

writeln('Tich cac so o vi tri le co gia tri chan la: ',s:4:2);

writeln('Cac so le la: ');

for i:=1 to n do 

  if a[i] mod 2<>0 then write(a[i]:4);

writeln;

writeln('Cac so chan va lon hon 10 la: ');

for i:=1 to n do 

  if (a[i] mod 2=0) and (a[i]>10) then write(a[i]:4);

readln;

end.

Bảo Nguyễn
Xem chi tiết