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 a,b:array[1..100]of integer;
i,n,kt,dem,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to a[i]-1 do
if a[i] mod j=0 then kt:=1;
if kt=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
end;
if dem=0 then writeln('Khong co so nguyen to trong day')
else begin
writeln('Cac so nguyen to trong day la: ');
for i:=1 to dem do
write(b[i]:4);
end;
readln;
end.
var a:array[1..1000] of integer;
i,n,d,max:integer;
begin
write('n = ');readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' = ');readln(a[i]);
if a[i] mod 2 <> 0 then d:=d+1;
end;
max:=a[1];
for i:=2 to n do
if a[i] > max then max:=a[i];
writeln('Co ',d,' so le');
write('So lon nhat la ',max);
readln
end.
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.
Program HOC24;
var x: integer;
begin
write('Nhap so: '); readln(x);
if x div 1000=1 then write('Mot nghin ');
if x div 1000=2 then write('Hai nghin ');
if x div 1000=3 then write('Ba nghin ');
if x div 1000=4 then write('Bon nghin ');
if x div 1000=5 then write('Nam nghin ');
if x div 1000=6 then write('Sau nghin ');
if x div 1000=7 then write('Bay nghin ');
if x div 1000=8 then write('Tam nghin ');
if x div 1000=9 then write('Chin nghin ');
if x div 1000<>0 then
if x div 100=0 then write('khong tram ');
if x div 100=1 then write('mot tram ');
if x div 100=2 then write('hai tram ');
if x div 100=3 then write('ba tram ');
if x div 100=4 then write('bon tram ');
if x div 100=5 then write('nam tram ');
if x div 100=6 then write('sau tram ');
if x div 100=7 then write('bay tram ');
if x div 100=8 then write('tam tram ');
if x div 100=9 then write('chin tram ');
if (x div 1000<>0) or (x div 100<>0) then
begin
if (x div 10<>0) then
begin
if x div 10=1 then write('muoi ');
if x div 10=2 then write('hai muoi ');
if x div 10=3 then write('ba muoi ');
if x div 10=4 then write('bon muoi ');
if x div 10=5 then write('nam muoi ');
if x div 10=6 then write('sau muoi ');
if x div 10=7 then write('bay muoi ');
if x div 10=8 then write('tam muoi ');
if x div 10=9 then write('chin muoi ');
if x mod 10=1 then write('mot');
if x mod 10=2 then write('hai');
if x mod 10=3 then write('ba');
if x mod 10=4 then write('bon');
if x mod 10=5 then write('lam');
if x mod 10=6 then write('sau');
if x mod 10=7 then write('bay');
if x mod 10=8 then write('tam');
if x mod 10=9 then write('chin');
end else
begin
if x mod 10=1 then write('le mot');
if x mod 10=2 then write('le hai');
if x mod 10=3 then write('le ba');
if x mod 10=4 then write('le tu');
if x mod 10=5 then write('le nam');
if x mod 10=6 then write('le sau');
if x mod 10=7 then write('le bay');
if x mod 10=8 then write('le tam');
if x mod 10=9 then write('le chin');
end;
readln
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 a,b,c:array[1..100]of integer;
i,n,dem,dem1,kt,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if sqrt(a[i])=trunc(sqrt(a[i])) then
begin
inc(dem);
b[dem]:=a[i];
end;
dem1:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then kt:=1;
if kt=0 then
begin
inc(dem1);
c[dem1]:=a[i];
end;
end;
if dem=0 then writeln('Trong day khong co so chinh phuong')
else begin
writeln('Cac so chinh phuong trong day la: ');
for i:=1 to dem do
write(b[i]:4);
end;
if dem1=0 then writeln('Trong day khong co so nguyen to')
else begin
writeln('Cac so nguyen to trong day la: ');
for i:=1 to dem1 do
write(c[i]:4);
end;
readln;
end.