Những câu hỏi liên quan
Lê Tâm Anh
Xem chi tiết
gấu béo
7 tháng 5 2023 lúc 19:20

program Le_Nho_Hon_Hoac_Bang_n;

uses crt;

var

       n, i: integer;

begin

       clrscr;

       write('Nhap vao mot so nguyen duong n: ');

       readln(n);

       while n <= 0 do

       begin

              writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');

              readln(n);

       end;

       clrscr;

       writeln('Cac so le nho hon hoac bang ', n, ' la:');

       i := 1;

       while i <= n do

       begin

              if i mod 2 <> 0 then

                     writeln(i);

              i := i + 1;

       end;

       readln;

end.

Bình luận (0)
nguyễn tiến thành
Xem chi tiết
Đặng Phương Linh
28 tháng 3 2023 lúc 5:32

for ... do

program Tinh_S;

uses crt;

var i,n:byte;

     S:longint;

begin

        writeln('Nhap so n='); readln(n);

       S:=0;

       for i:=1 to n do 

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

       writeln('Tong cac so le nho hon hoac bang n la, S=',S)

       readln

end.

 

 

 

Bình luận (2)
Thanh Phong (9A5)
28 tháng 3 2023 lúc 5:36

* While....do

Uses crt;

var n,i,k: integer;

begin clrscr;

readln(n);

i:=0;

while(i<=n) do begin

i:=i+1;

if(i mod 2<>0) then k:=k+i;

end;

writeln(k);

readln;

end.

* for...do

Uses crt;

var n,i,u: integer;

begin clrscr;

readln(n);

for i:=1 to n do if(i mod 2<>0) then u:=u+i;

writeln(u);

readln;

end.

Bình luận (2)
Đặng Phương Linh
28 tháng 3 2023 lúc 5:36

while... do

program Tinh_P;

uses crt;

var i,n:byte;

      P:longint;

begin

         writeln('Nhap so n='); readln(n);

        P:=0; i:=1;

        while i<=n do

          begin

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

             i:=i+1;

          end;

       writeln('Tong so le nho hon hoac bang n la, P=',P);

       readln

end.

 

 

       

         

Bình luận (0)
Cao Ngọc Bảo Quyên
Xem chi tiết
Hương Đào Thị
Xem chi tiết
Hương Đào Thị
21 tháng 2 2022 lúc 17:05

giúp mình với

 

Bình luận (2)
Tòi >33
21 tháng 2 2022 lúc 17:58

tham khảo 

Program HOC24;

var n: byte;

begin

n:=0;

while n<50-1 do n:=n+1;

write('N=',N); 

readln

end.

Bình luận (0)
Minh Lệ
21 tháng 2 2022 lúc 17:58

Ở đây b nhé: Câu trả lời

Bình luận (0)
Gà Công Nghệ
Xem chi tiết
Anh Phạm
28 tháng 8 2021 lúc 19:43

uses crt;

var n,i,o,d:integer;

function ktnt(n:integer): integer;

var i,d:integer;

begin

d:=0;

for i:=1 to sqrt(n) do

if (n mod i=0) then d:=d+1;

if d=2 then ktnt=0

else ktnt=1;

end;

begin

readln(n);

writeln(' so nguyen to be hon hoac bang n la'); {a}

for i:=1 to n do

if ktnt(i)=0 then writeln(i);

writeln('so nguyen to nho nhat khong be hon n');

o:=n;

while o>0 do

begin

if ktnt(o)=0 then

begin

write(o);

break;

end;

o:=o+1;

end;

writeln('cặp số nguyên tố là hai số nguyên lẻ liên tiếp nhỏ hơn hoặc bằng n');

o:=0;

o:=1;

d:=0;

for i:=o+2 to n do

begin

if ktnt(i)=0 then

begin

d:=d+1;

write(i,' ');

if d<2 then continue;

end;

d:=0;

writeln;

end;

readln;

end.

Bình luận (1)
Thiên Ân Nguyễn
Xem chi tiết
Kiều Vũ Linh
20 tháng 4 2022 lúc 20:35

Var n,i,so:integer;

Begin

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

For i:=1 to n do

Begin

Write('Nhap so thu ',i,' = ');readln(so);

If so mod 2 = 0 then writeln(so);

End;

Readln;

End.

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

#include <bits/stdc++.h>

using namespace std;

int i,n;

int main()

{

cin>>n;

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

if (i%2==1) cout<<i<<" ";

return 0;

}

Bình luận (0)
Kisaragi Saya
Xem chi tiết
Đỗ Tuệ Lâm
17 tháng 2 2022 lúc 7:10

{program bt_1;
uses crt;
Var:S ,n, i, j:longint;
Begin 
  clrsr;
  Write('Nhap n');Readln(n);
    For i:=1 to n do
    Begin
      S:=0;
      For j:=0 to i do
      if i mod j:=0 then S:=S+j;
      if S=2*i then Write (i:5);
    end;
readln;
end.
}

Bình luận (0)
Lưu Nguyễn Hải Nam
6 tháng 12 2023 lúc 18:54

PASSCAL HAY???

 

Bình luận (0)
Kamato Heiji
Xem chi tiết
Minh Lệ
13 tháng 3 2021 lúc 14:18

Cách 1: while..do

Program HOC24;

var i: integer;

begin

i:=1;

while i<30 do

begin

write(i,' ');

i:=i+1;

end;

readln

end.

Cách 2: for..do

Program HOC24;

var i: integer;

begin

for i:=1 to 29 do write(i,' ');

readln

end.

Bình luận (0)