Những câu hỏi liên quan
Eliette
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 22:51

Câu 1: 

uses crt;

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

i,n,t,s:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=0;

s:=1;

dem:=0;

for i:=1 to n do 

  if a[i] mod 3=0 then 

begin

inc(dem);

t:=t+a[i];

s:=s*a[i];

end;

if dem=0 then writeln('Khong co so chia het cho 3 trong day')

else begin

writeln('Tong cac so chia het cho 3 la: ',t);

writeln('Tich cac so chia het cho 3 la: ',s);

end;

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 22:51

Câu 2: 

uses crt;

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

i,n,dem,t:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

dem:=0;

t:=0;

for i:=1 to n do 

 if a[i] mod 2=0 then 

begin

inc(dem);

t:=t+a[i];

end;

writeln('So so chan la: ',dem);

writeln('Tong cac so chan la: ',t);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 22:55

Câu 3: 

uses crt;

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

i,n,dem1,dem2,t1,t2,s1,s2:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

dem1:=0;

dem2:=0;

t1:=0;

t2:=0;

s1:=1;

s2:=1;

for i:=1 to n do

begin

if a[i] mod 2=0 then 

begin

inc(dem1);

t1:=t1+a[i];

s1:=s1*a[i];

end

else begin

inc(dem2);

t2:=t2+a[i];

s2:=s2*a[i];

end;

end;

if dem1=0 then writeln('Khong co so chan trong day')

else begin

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

writeln('Tong cac so chan la: ',t1);

writeln('Tich cac so chan la: ',s1);

end;

if dem2=0 then writeln('Khong co so le trong day')

else begin

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

writeln('Tong cac so le la: ',t2);

writeln('Tich cac so le la: ',s2);

end;

readln;

end.

Bình luận (0)
Huyền
Xem chi tiết
HT.Phong (9A5)
28 tháng 4 2023 lúc 16:21

Uses crt;

var i,t: integer;

begin clrscr;

i:=0;

while(i<=120) do begin

i:=i+1;

t:=t+i;

end;

write(t);

readln;

end.

Bình luận (0)
Xem chi tiết
Minh Lệ
15 tháng 3 2021 lúc 19:04

Program HOC24;

var a: real;

i,n: integer;

begin

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

a:=0;

for i:=1 to n do a:=a+1/i;

write('A= ',a);

readln

end.

Bình luận (0)
Đặng Nguyễn Hoài Băng
Xem chi tiết

#include <bits/stdc++.h>
using namespace std;
int n,x,i,rel=0,rec=0;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for(i=0;i<n;i++)
{
    cin>>x;
    if(x%2==0) rec+=x;
    else rel+=x;
}
cout<<"tong chan cua cac phan tu chan la: "<<rec<<"\n";
cout<<"tong chan cua cac phan tu le la: "<<rel<<"\n";

return 0;
}

 

 

Bình luận (0)
Ngọc Tú
Xem chi tiết
HT.Phong (9A5)
7 tháng 3 2023 lúc 16:37
Bình luận (0)
Minh Lệ
7 tháng 3 2023 lúc 17:03

Program HOC24;

var i: byte;

t: real;

begin

t:=0;

for i:=1 to 100 do t:=t+1/i;

write('T= ',t:5:2);

readln

end.

Bình luận (0)
Lê Thanh Tuyền
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 2 2021 lúc 11:58

Bài 1: 

function canbac2(x:longint):real;

begin

canbac2:=sqrt(x);

end;

Bài 2: 

function tong(n:longint):longint;

var s,i:longint;

begin

s:=0;

for i:=1 to n do 

  s:=s+i;

tong:=s;

end;

Bình luận (0)
PC Vũ
Xem chi tiết
Minh Lệ
11 tháng 5 2021 lúc 1:42

Program HOC24;

var i: integer;

s: real;

begin

s:=0;

for i:=1 to 100 do s:=s+1/i;

write('S= ',s:2:2);

readln

end.

Bình luận (0)
Nguyễn Võ Phương Uyên
Xem chi tiết
Cương Kim
Xem chi tiết
Phía sau một cô gái
25 tháng 4 2023 lúc 20:17

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

tong = 0

for i in range(1, n):

      if i % 3 == 0:

            tong += i

print("Tong cac so chia het cho 3 tu 1 den", n-1, "la:", tong)

Bình luận (0)