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
Tuyết Lê
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 3 2021 lúc 13:23

Bài 1: 

uses crt;

var n,i:integer;

s:real;

begin

clrscr;

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

s:=1;

for i:=1 to n do 

 s:=s*i;

writeln(n,'!=',s:0:0);

readln;

end.

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

1).

program oken;

uses crt;

var n,i: integer;

      gt: qword;

begin

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

gt:=1;

for i:=1 to n do gt:=gt*i;

writeln('N!=',gt);

readln;

end.

2).

program tongcacsole;

uses crt;

var t,i:longint;

begin

clrscr;

for i:=1 to 203 do 

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

write(t);

end.

3).

program tongcacsochan;

uses crt;

var t,i:longint;

begin

clrscr;

for i:=1 to 20 do 

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

write(t);

end.

phamthiminhanh
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 1 2021 lúc 20:13

Câu 1: 

uses crt;

var a,b:integer;

begin

clrscr;

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

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

if (a>0) and (b>0) then writeln('Cung duong');

if (a<0) and (b<0) then writeln('Cung am');

if (a>0) and (b<0) then writeln('Duong am');

if (a<0) and (b>0) then writeln('Am duong');

readln;

end.

Câu 2: 

uses crt;

var a,b:integer;

begin

clrscr;

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

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

if (a mod 2=0) and (b mod 2=0) then writeln('Cung chan');

if (a mod 2<>0) and (b mod 2<>0) then writeln('Cung le');

if (a mod 2=0) and (b mod 2<>0) then writeln('Chan le');

if (a mod 2<>0) and (b mod 2=0) then writeln('Le chan');

readln;

end.

Hoshimiya Akari
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:15

Bài 1: 

uses crt;

var m,n,i,t:integer;

begin

clrscr;

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

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

t:=0;

for i:=m to n do 

  t:=t+i;

writeln(t);

readln;

end.

Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:17

2:

uses crt;

var n:integer;

{---------------chuong-trinh-con-kiem-tra-chan-le---------------------}

function ktcl(x:integer):boolean;

begin

if x mod 2=0 then ktcl:=true

else ktcl:=false;

end;

{--------------------chuong-trinh-con-kiem-tra-duong-am-------------------}

fucntion ktda(x:integer):boolean;

begin

if x>0 then ktda:=true

else if x<0 then ktda:=false;

end;

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

begin

clrscr;

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

if ktcl(n)=true then writeln('Day la so chan')

else writeln('Day la so le');

if ktda(n)=true then writeln('Day la so duong')

else writeln('Day la so am');

readln;

end.

Bảo Trâm
Xem chi tiết
Nguyễn Lê Phước Thịnh
6 tháng 4 2022 lúc 23:03

 

 

#include <bits/stdc++.h>

using namespace std;

long long n,i,t;

int main()

{

cin>>n;

t=0;

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

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

cout<<t;

return 0;

}

 

Ánh sao
Xem chi tiết
Phạm Nguyễn Hồng Anh
28 tháng 2 2021 lúc 16:45

câu 1:

uses crt;

var p,i:integer;

begin

clrscr;

p:=1;i:=1;while i<=5 do

begin

p:=p*i;i:=i+1;

end;

write(p);

readln;

end. 

bai 2:

uses crt;var p,i:integer;begin    clrscr;    p:=1; i:=0;    while i <=10 do    begin

i:=i+1;        if (i mod 2<>0) then p:=p*i;    end;    write(p);    readln;end. bai 3:

uses crt;var n,i,p:integer;begin     clrscr;     write('nhap n: ');     readln(n);     i:=1;     p:=1;     while i<=n do     begin       if i mod 2=0 then p:=p*i;       i:=i+1;     end;     write(p);     readln;end.     

 

Nguyễn Lê Phước Thịnh
28 tháng 2 2021 lúc 19:17

*Cách khác: Dùng for

Câu 1: 

uses crt;

var p,i:longint;

begin

p:=1;

for i:=1 to 4 do 

  p:=p*i;

writeln(p);

readln;

end.

Câu 2: 

uses crt;

var i,s:longint;

begin

clrscr;

s:=1;

for i:=1 to 10 do

  if i mod 2=1 then s:=s*i;

writeln(s);

readln;

end.

Câu 3: 

uses crt;

var n,i,s:longint;

begin

clrscr;

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

s:=0;

for i:=1 to n do 

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

writeln(s);

readln;

end.

Nguyễn Cảnh Hùng
Xem chi tiết
Đỗ Ngọc Trinh
30 tháng 5 2017 lúc 6:52

Tuyết Lê
Xem chi tiết
Minh Lệ
27 tháng 2 2021 lúc 12:54

For i:=1 to 20 do if i mod 2=1 then t:=t+i;

Dương Ngọc Nguyễn
27 tháng 2 2021 lúc 12:55

T:=0;

for i:= 1 to 20 do

If i mod 2 = 1 then tong:=i + T;

Nguyễn Lê Phước Thịnh
27 tháng 2 2021 lúc 18:48

*Cách khác

for i:=1 to n do 

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

Bảo Trâm
Xem chi tiết
Nguyễn Lê Phước Thịnh
6 tháng 4 2022 lúc 23:03

#include <bits/stdc++.h>

using namespace std;

long long n,i,t;

int main()

{

cin>>n;

t=0;

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

if (i%2==0) t+=i;

cout<<t;

return 0;

}

Nguyễn Cảnh Hùng
Xem chi tiết
Đỗ Ngọc Trinh
1 tháng 4 2019 lúc 2:31

Program bt_3;

Uses crt;

Var Tong, n, i: integer;

Begin

 Clrscr;

 Writeln(‘nhap n=’);

 Readln (n);

 Tong:=0;

 For i:=1 to n do

 If I mod 2 = 1 then Tong:= Tong+i;

 Writeln(‘Tong la:’,Tong);

 Readln

End.