Bạn chưa đăng nhập. Vui lòng đăng nhập để hỏi bài

Những câu hỏi liên quan
Hoài thịnh
Xem chi tiết
Hoàng Như Anh
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 2 2022 lúc 23:31

#include <bits/stdc++.h>

using namespace std;

long long n,i,s;

int main()

{

cin>>n;

if (n%2==0)

{

s=1;

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

if (i%2==0) s=s*i;

cout<<s;

}

else 

{

s=1;

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

if (i%2==1) s=s*i;

cout<<s;

}

return 0;

}

Phạm thị thảo ly
Xem chi tiết
Đỗ Tuệ Lâm
20 tháng 3 2022 lúc 15:20

undefined

Minh Lệ
20 tháng 3 2022 lúc 18:49

Program HOC24;

var i,n: integer;

S,P: longint;

begin

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

{..............................................}

readln

end.

-----------------------------------------------------------

Bạn điền vào {........................} theo từng bài nhé

a) S:=0; 

for i:=1 to N do if i mod 2=1 then s:=s+i;

write('S= ',s);

b)

S:=0;

for i:=1 to N do if i mod 2=0 then s:=s+i;

write('S= ',s);

c) P:=1;

for i:=1 to N do if i mod 2=0 then p:=p*i;

write('P= ',p);

d)

P:=1;

for i:=1 to N do if i mod 2=1 then p:=p*i;

write('P= ',p);

Trần Ngọc Hảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 12 2020 lúc 23:26

uses crt;

var n,d,dem,i,x,y,t:integer;

st:string;

begin

clrscr;

repeat

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

until (1000<=n) and (n<=9999);

if n mod 2=0 then 

  begin

     str(n,st);

d:=length(st);

dem:=0;

for i:=1 to d do

  begin

val(st[i],x,y);

if x=0 then inc(em);

end; 

writeln('So chu so 0 co trong so ',n,' la: ',dem);

end

else begin

str(n,st);

t:=0;

d:=length(st);

for i:=1 to d do 

  begin

val(st[i],x,y);

t:=t+sqr(x);

end;

writeln('Tong binh phuong cac chu so trong so ',n,' la: ',t);

end;

readln;

end.

Lê Chiêu Nguyên	Vũ
4 tháng 4 2023 lúc 10:09

uses crt;

var n,d,dem,i,x,y,t:integer;

st:string;

begin

clrscr;

repeat

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

until (1000<=n) and (n<=9999);

if n mod 2=0 then 

  begin

     str(n,st);

d:=length(st);

dem:=0;

for i:=1 to d do

  begin

val(st[i],x,y);

if x=0 then inc(em);

end; 

writeln('So chu so 0 co trong so ',n,' la: ',dem);

end

else begin

str(n,st);

t:=0;

d:=length(st);

for i:=1 to d do 

  begin

val(st[i],x,y);

t:=t+sqr(x);

end;

writeln('Tong binh phuong cac chu so trong so ',n,' la: ',t);

end;

readln;

end.

Giang Hồ
Xem chi tiết
Lê Tiến Thành
Xem chi tiết
Duy Nam
7 tháng 3 2022 lúc 8:14

uses crt;

var m,n,t,i:integer;

begin

clrscr;

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

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

t:=0;

for i:=m to n do 

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

writeln('Tong cac so chan tu ',m,' den ',n,' la: ',t);

readln;

end.

Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 6:59

#include <bits/stdc++.h>

using namespace std;

long long n,i,t;

int main()

{

cin>>n;

if (n%2==0)

{

t=0;

for (i=1; i<=n; i++) if (i%2==0) t+=i;

}

else 

{

t=0;

for (i=1; i<=n; i++) if (i%2!=0) t+=i;

}

cout<<t;

return 0;

}

Lê Tiến Thành
Xem chi tiết
Vũ Quang Huy
12 tháng 3 2022 lúc 9:26

tk

uses crt;

var m,n,t,i:integer;

begin

clrscr;

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

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

t:=0;

for i:=m to n do 

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

writeln('Tong cac so chan tu ',m,' den ',n,' la: ',t);

readln;

end.

Nguyễn Lê Phước Thịnh
14 tháng 3 2022 lúc 15:55

uses crt;

var n,i,t,dem:integer;

begin

clrscr;

readln(n);

if n mod 2=0 then 

begin

t:=0;

for i:=1 to n do 

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

writeln(t);

end

else 

begin

t:=0;

dem:=0;

for i:=1 to n do 

 if i mod 2=1 then 

begin

t:=t+i;

dem:=dem+1;

end;

writeln(t/dem:4:2);

end;

readln;

end.

Krissy
Xem chi tiết

S=1+4+7+..+n

Tổng S có số số hạng là \(\frac{\left(n-1\right)}{3}+1=\frac{n+2}{3}\)

Tổng S có giá trị là

\(S=\frac{\left(n+1\right)}{2}.\frac{n+2}{3}=\frac{\left(n+1\right)\left(n+2\right)}{6}\)

Thành Tân B1-
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 12 2021 lúc 8:42

Bài 2: 

uses crt;

var x,i,n,dem:integer;

begin

clrscr;

readln(n);

dem:=0;

for i:=1 to n do 

begin

readln(x);

if x mod 2=0 then inc(dem);

end;

writeln(dem);

readln;

end.