Những câu hỏi liên quan
nguyễn an phát
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 3 2021 lúc 19:52

a)

uses crt;

var n,i,kt,j:integer;

begin

clrscr;

repeat

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

until n>1;

writeln('Cac so nguyen to be hon hoac bang ',n,' la: ');

for i:=2 to n do 

begin

kt:=0;

for j:=2 to i-1 do 

  if i mod j=0 then kt:=1;

if kt=0 then write(i:4);

end;

readln;

end.

Bình luận (0)
Lily Minamoto
Xem chi tiết
nguyễn an phát
26 tháng 5 2021 lúc 11:36

program so_nguyen_to;

uses crt;

var i,n:integer;

function kt(n:integer):boolean;

var i,j:integer;

begin

j:=0;

for i:=1 to n do

if n mod i=0 then inc(j);

if j=2 then kt:=true

else kt:=false;

end;

BEGIN

clrscr;

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

if kt(n) then writeln(n,' la so nguyen to')

else writeln(n,' khong phai la so nguyen to');

writeln('cac so nguyen to be hon hoac bang ',n,' la:');

for i:=1 to n do

if kt(i) then write(i:5);

writeln;

writeln('cac cap so le lien tiep la so nguyen to be hon hoac bang ',n,' la:');

for i:=1 to n do

if (i mod 2=1) and (kt(i)) and (kt(i+2)) then write(i,',',i+2);

readln;

end.

Bình luận (1)
nguyễn an phát
26 tháng 5 2021 lúc 11:39

câu c bạn viết cách ra nhé!

Bình luận (0)
Phan Đức Duy
Xem chi tiết
hacker
10 tháng 1 2021 lúc 17:31

uses crt;var n: longint;    chrn: string;    valn,sum,max,i,preperror: byte;begin    write('Nhap so can kiem tra: ');    readln(n);    str(n,chrn);    for i:=1 to length(chrn) do    begin        val(chrn[i],valn,preperror);        sum:=sum+valn;        if max<valn then max:=valn;        valn:=0    end;    writeln('Ket qua: ');    writeln(length(chrn));    writeln(sum);    write(max);    readln;end.uses crt;var n: longint;    chrn: string;    valn,sum,max,i,preperror: byte;begin    write('Nhap so can kiem tra: ');    readln(n);    str(n,chrn);    for i:=1 to length(chrn) do    begin        val(chrn[i],valn,preperror);        sum:=sum+valn;        if max<valn then max:=valn;        valn:=0    end;    writeln('Ket qua: ');    writeln(length(chrn));    writeln(sum);    write(max);    readln;end.

Bình luận (0)
Minh Lệ
10 tháng 1 2021 lúc 20:09

Program HOC24;

var N:longint;

max,tg,t,d: integer;

Begin

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

max:=0;

while n<>0 do

begin

tg:=n mod 10;

d:=d+1;

t:=t+tg;

if tg>max then max:=tg;

n:=n div 10;

end;

writeln('So nguyen N co ',d,' chu so');

writeln('Tong cac chu so cua N la : ',t);

write('Chu so lon nhat cua N la :',max);

readln

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
10 tháng 1 2021 lúc 20:11

uses crt;

var n,d,i,t,max,x:longint;

y:integer;

st:string;

begin

clrscr;

repeat

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

until n>0;

str(n,st);

d:=length(st);

writeln('So chu so cua ',n,' la: ',d);

t:=0;

max:=0;

for i:=1 to d do 

  begin

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

t:=t+x;

if max<x then max:=x;

end;

writeln('Tong cac chu so cua ',n,' la: ',t);

writeln('Chu so lon nhat cua ',n,' la: ',max);

readln;

end.

Bình luận (0)
trần hoàng
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 4 2022 lúc 21:53

#include <bits/stdc++.h>

using namespace std;

long long i,n,kt,j;

int main()

{

cin>>n;

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

{

kt=0;

for (j=2; j*j<=i; j++)

if (i%j==0) kt=1;

if (kt==0) cout<<i<<" ";

}

return 0;

}

Bình luận (0)
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)
Ly Khánh
Xem chi tiết
lân đinh
Xem chi tiết
Nguyễn Lê Phước Thịnh
11 tháng 5 2021 lúc 10:50

Bài 3:

uses crt;

var i:integer;

{------------------chuong-trinh-con-kiem-tra-so-nguyen-to----------------------}

function ktnt(x:integer):boolean;

var kt:boolean;

i:integer;

begin

kt:=true;

for i:=2 to x-1 do

  if x mod i=0 then kt:=false;

if kt=true then ktnt:=true

else ktnt:=false;

end;

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

begin

clrscr;

for i:=2 to 9999 do 

  if (ktnt(i)=true) and (ktnt(i+2)=true) then 

begin

writeln(i,',',i+2);

delay(500);

end;

readln;

end.

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

Bài 4: 

uses crt;

var a,b,c,kt:integer;

begin

clrscr;

write('Nhap ngay:'); readln(a);

write('Nhap thang:'); readln(b);

write('Nhap nam:'); readln(c);

kt:=0;

if (b=1) and (0<a) and (a<=31) then kt:=1;

if (b=2) and (0<a) and (a<=28) then kt:=1;

if (b=2) and (0<a) and (a<=29) and (c mod 4=0) then kt:=1;

if (b=3) and (0<a) and (a<=31) then kt:=1;

if (b=4) and (0<a) and (a<=30) then kt:=1;

if (b=5) and (0<a) and (a<=31) then kt:=1;

if (b=6) and (0<a) and (a<=30) then kt:=1;

if (b=7) and (0<a) and (a<=31) then kt:=1;

if (b=8) and (0<a) and (a<=31) then kt:=1;

if (b=9) and (0<a) and (a<=30) then kt:=1;

if (b=10) and (0<a) and (a<=31) then kt:=1;

if (b=11) and (0<a) and (a<=30) then kt:=1;

if (b=12) and (0<a) and (a<=31) then kt:=1;

if kt=0 then writeln('Khong hop le')

else writeln('Hop le');

readln;

end.

Bình luận (0)
Lê Thị Cẩm Tiên
9 tháng 7 2021 lúc 10:30

Bạn ơi bạn làm ra bài 3 chưa, cho mình xin cách làm nữa.

Python

Bình luận (0)
minh dương
Xem chi tiết
Linh Đan
Xem chi tiết
Võ Đức Dũng
17 tháng 9 2021 lúc 21:33

câu 1

Program Nguyen_to;

Var n,i:integer;

Function NT(n:integer):Boolean;

Var ok: Boolean;

i: integer;

Begin ok:=true;

for i:=2 to n-1 do if (n mod i)= 0 then ok:=ok and false;

if n < 2 then NT:=false else NT:=ok;

End;

Begin Write('Nhap n: ');

Readln(n); i:=n;

Repeat i:=i+1;

Until NT(i);

Write('So nguyen to nho nhat lon hon ',n, 'la: ',i);

Readln End.

Bình luận (1)
Võ Đức Dũng
17 tháng 9 2021 lúc 21:39

câu 2

uses crt;

const so: set of char=['0','1','2','3','4','5','6','7','8','9'];

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

st,b:string;

c,l,i,n,j:integer;

s, Max: integer;

begin clrscr;

write('Nhap xau:');

readln(st);

l:=length(st);

i:=1;

n:=0;

repeat if (st[i] in so) then begin b:=''

repeat b:=b+st[i];

inc(i);

until (not(st[i] in so)) or (i>l);

inc(n);

val(b,a[n],c);

end;

inc(i);

until i>l;

Max:=a[1];

for i:=2 to n do If Max<A[i] Then Max:=A[i];

Writeln('Phan tu lon nhat cua mang:', Max);

readln;

end.

Bình luận (0)