Những câu hỏi liên quan
Tai Lam
Xem chi tiết
ERROR
9 tháng 5 2022 lúc 21:47

refer

program dem;

uses crt;

var n,i,j,S: integer;

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

begin

i:=0;

S:=0;

while(readln(n)) do

begin

 if(n:=0) then break;

 i:=i+1;

 a[i]:=n;

end;

for j:=1 to i do 

begin

 if(a[j] mod 2 <> 0) then S:=S+a[j];

end;

write(‘Tong cua cac so le la: ‘,S);

readln;

Bình luận (0)
Logan
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 9 2021 lúc 21:40

uses crt;

var n,t:integer;

{------------------kiem-tra-so-nguyen-to----------------------------}

function ktnt(x:integer):boolean;

var i:integer;

kt:boolean;

begin

kt:=true;

for i:=2 to trunc(sqrt(x)) do 

  if x mod i=0 then 

begin

kt:=false;

break;

end;

if kt=true then ktnt:=true

else ktnt:=false;

{----------------------chuong-trinh-chinh------------------------}

begin

clrscr;

t:=0;

repeat

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

if (n mod 2=0) then t:=t+n;

until ktnt(n)=false;

writeln(t);

readln;

end.

Bình luận (0)
việt hoàng
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 1 2022 lúc 7:43

Bài 1: 

#include <bits/stdc++.h>

using namespace std;

long long a[10],n,i,t;

int main()

{

n=0;

do 

{

cin>>a[i];

}

while ((a[i]==0) or (n==10));

for (i=1; i<=n; i++) cout<<a[i]<<" ";

cout<<endl;

t=0;

for (i=1; i<=n; i++)

if (a[i]%2!=0) t=t+a[i];

cout<<t;

return 0;

}

Bình luận (1)
Mon Mon
Xem chi tiết
Phía sau một cô gái
14 tháng 3 2023 lúc 15:17

so_am = 0

so_duong = 0

while True:

     n = int(input("Nhap vao mot so nguyen: "))

     if n == 0:

          break

     elif n < 0:

          so_am += 1

     else:

          so_duong += 1

print("So am: ", so_am)

print("So duong: ", so_duong)

Bình luận (0)
depzaivl
Xem chi tiết
Ngô Bá Hùng
3 tháng 5 2023 lúc 8:21

count_even = 0
count_odd = 0

while True:
    num = int(input("Nhap so nguyen: ")) //0 de kthuc
    if num == 0:
        break
    
    if num % 2 == 0:
        count_even += 1
    else:
        count_odd += 1

print("Số lẻ:", count_odd)
print("Số chẵn:", count_even)

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

uses crt;

var n,i,t1,t2:integer;

begin

clrscr;

t1:=0;

t2:=0;

repeat

readln(n);

if n mod 2=0 then t1:=t1+n

else t2:=t2+n;

until n=0;

writeln(t1,' ',t2);

readln;

end.

Bình luận (0)
日光
Xem chi tiết
Ng Ngọc
10 tháng 3 2022 lúc 9:46

???

Bình luận (0)
Kaito Kid
10 tháng 3 2022 lúc 9:46

???

Bình luận (0)
Keiko Hashitou
10 tháng 3 2022 lúc 9:46

ko đăng linh tinh

Bình luận (0)
Trần Đức Huy
Xem chi tiết
Minh Lệ
14 tháng 3 2023 lúc 21:25

Program HOC24;

var i,n: integer;

t: longint;

begin

write('Nhap so: ');

readln(n);

if n mod 2=0 then t:=n else t:=0;

while n<>0 do

begin

write('Nhap so: ');

readln(n);

if n mod 2=0 then t:=t+n;

end;

write('Ket qua la: ',t);

readln

end.

Bình luận (0)
Hồ Thị Hải Ngân
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 4 2021 lúc 19:25

uses crt;

var a,t:integer;

begin

clrscr;

t:=0;

repeat

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

t:=t+a;

until a=0;

writeln(t);

readln;

end.

Bình luận (0)