Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
uses crt;
var n,i,dem,j,t:integer;
kt:boolean;
begin
clrscr;
readln(n);
t:=0;
for i:=2 to n do
begin
kt:=true;
for j:=2 to i-1 do
if i mod j=0 then kt:=false;
if kt=true then
begin
write(i:4);
t:=t+i;
end;
end;
writeln;
writeln(t);
readln;
end.
uses crt;
var i,n,t,j,kt:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=2 to n do
if n mod i=0 then
begin
kt:=0;
for j:=2 to trunc(sqrt(i)) do
if i mod j=0 then kt:=1;
if kt=0 then t:=t+i;
end;
write(t);
readln;
end.
Program HOC24;
var st,st1,st2: string;
i: byte;
f: text;
const fi='SPLIT.INP ' ;
fo = 'SPLIT.OUT' ;
Procedure ip;
begin
assign(f,fi);
reset(f);a
read(f,st);
close(f);
end;
Procedure out;
begin
assign(f,fo);
rewrite(f);
st1:=''; st2:='';
for i:=1 to length(st) do
begin
if st[i] in ['A'..'z'] then st1:=st1+st[i];
if st[i] in ['0'..'9'] then st2:=st2+st[i];
end;
writeln(f,st1);
write(f,st2);
close(f);
end;
Begin
ip;
out;
End.
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.
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.
uses crt;
var n,i,chan,tonchan:integer;
a:array[1..100] of integer;
begin
write('nhap n '); readln(n);
for i:=1 to n do
begin
write('a[i]='); readln(a[i]);
end;
writeln("in cac phan tu trong mang");
for i:=1 to n do
begin
writeln(a[i]);
end;
writeln("in cac phan tu chan");
chan:=0;
for i:=1 to n do
if n mod 2=0 then begin writeln(a[i]); chan:=chan+1; end;
write('tong cac phan tu chan ',chan);
readln;
end.
program abcdef;
uses Crt;
var
k, lowerLimit, upperLimit, i, j, reversed, temp, remainder: integer;
isPrime, isPalindrome: boolean;
begin
clrscr;
write('Nhap so chu so k (1<=k<=9): ');
readln(k);
lowerLimit := 1;
for i := 1 to k - 1 do
lowerLimit := lowerLimit * 10;
upperLimit := lowerLimit * 10 - 1;
writeln('Cac so nguyen to doi xung co ', k, ' chu so la:');
for i := lowerLimit to upperLimit do
begin
// Kiểm tra số nguyên tố
isPrime := True;
if i < 2 then
isPrime := False
else
for j := 2 to trunc(sqrt(i)) do
if i mod j = 0 then
beginisPrime := False;break;end;
// Kiểm tra số đối xứng
if isPrime then
begin
reversed := 0;
temp := i;
while temp <> 0 dobeginremainder := temp mod 10;
reversed := reversed * 10 + remainder;
temp := temp div 10;
end;
isPalindrome := (i = reversed);
if isPalindrome then
writeln(i);
end;
end;
readln;
end.
uses crt;
Var i,n,dem:integer;
a: array[1..1000] of integer;
Begin
clrscr;
Write('Nhap do dai cua day: ');readln(n);
dem:=0;
for i:= 1 to n do
Begin
write('So thu ',i,' = ');
readln(a[i]);
if a[i] mod 2 = 0 then inc(dem);
end;
Writeln('Day so co ',dem,' so chan');
readln;
End.
Program HOC24;
var i: integer;
function nt(x: integer): boolean;
var j: integer;
begin
nt:=true;
if (x=2) or (x=3) then exit;
nt:=false;
if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;
j:=5;
while j<=trunc(sqrt(x)) do
begin
if (x mod j=0) or (x mod (j+2)=0) then exit;
j:=j+6;
end;
nt:=true;
end;
Begin
for i:= 10 to 99 do if nt(i) and i mod 2=0 then write(i,' ');
readln
end.