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,kt,snt,b,m:longint;
{-----------------------------}
procedure nhap(var a:longint);
begin
write('nhap n:'); readln(a);
end;
{-------------------------------------------}
function ktnt(var x:longint):integer;
var kt,i,kt1,j:integer;
begin
kt:=0;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then
begin
kt:=1;
break;
end;
if kt=0 then ktnt:=1
else ktnt:=0;
end;
{-----------------------------------------------------}
BEGIN
clrscr;
nhap(n);
for m:=10 to n do
{-----------------------------------------------}
begin
begin
b:=m;
repeat
kt:=ktnt(b);
if kt=0 then break
else b:=b div 10;
until b<10;
if (ktnt(b)=1) and (b>1) then write(m,' ')
end;
end;
{-------------------------------------------------}
readln;
END.
uses crt;
var a,b:longint;
st:string;
nt:array[1..100]of int64;
t,i,j,dem,kt,kt1,d,dnt:integer;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
dem:=0;
for t:=a to b do
begin
str(t,st);
kt:=0;
d:=length(st);
for i:=1 to d do
if st[i]<>st[d-i+1] then kt:=1;
if kt=0 then
begin
dem:=dem+1;
nt[dem]:=t;
end;
end;
dnt:=0;
for i:=1 to dem do
begin
kt1:=0;
for j:=2 to nt[i]-1 do
if nt[i] mod j=0 then kt1:=1;
if kt1=0 then dnt:=dnt+1;
end;
writeln('so luong cac so nguyen to doi xung thoa man lon hon hoac bang ',a,' va nho hon hoac bang ',b,' la: ',dnt);
readln;
end.
uses crt;
var a,b:longint;
st:string;
nt:array[1..100]of int64;
t,i,j,dem,kt,kt1,d,dnt:integer;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
dem:=0;
for t:=a to b do
begin
str(t,st);
kt:=0;
d:=length(st);
for i:=1 to d do
if st[i]<>st[d-i+1] then kt:=1;
if kt=0 then
begin
dem:=dem+1;
nt[dem]:=t;
end;
end;
dnt:=0;
for i:=1 to dem do
begin
kt1:=0;
for j:=2 to nt[i]-1 do
if nt[i] mod j=0 then kt1:=1;
if kt1=0 then dnt:=dnt+1;
end;
writeln('so luong cac so nguyen to doi xung thoa man lon hon hoac bang ',a,' va nho hon hoac bang ',b,' la: ',dnt);
readln;
end.
Câu 1:
uses crt;
var a,b:integer;
begin
clrscr;
readln(a,b);
writeln((a+b)/2:4:2);
readln;
end.
Program ct;
Var i,n,so le, so chan:integer;
B:Array[1..n] of integer;
Begin
Write('n=');Readln(n);
For i:=1 to n do begin Write('B[',i,']=');
Readln(B[i]);
End;
For i:=1 to n do Begin
if B[i] mod 2 <>0 then writeln('so le , ' );
If B[i] mod 2=0 then writeln('so chan ,' );
End;
Readln
End.
Lời giải:
Bài 1 :
a) var A : array[1..100] of real ;
b) var B : array[1..20] of integer ;
c) A[7] := 8 ;
Bài 2 :
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n: integer ;
begin
write('nhap do dai cua mang'); readln(n);
write('Nhap cac gia tri cua phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
readln
end.
Bài 3 :
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n: integer ;
begin
write('Co tat ca so ban hoc sinh la'); readln(n);
write('Nhap diem mon tin cua cac ban');
for i:= 1 to n do
begin
write('Ban thu ',i,':'); readln(a[i]);
end;
readln
end.
Bài 4 : a,b giống bài 3
c)
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n,tong : integer ;
begin
write('nhap do dai cua mang'); readln(n);
write('Nhap cac gia tri cua phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
tong:=0;
for i:= 1 to n do
if a[i] > 0 then tong:=tong+1;
write('Ket qua la',tong);
readln
end.
Bài 5: a và b tương tự bài 3
c+d )
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n: integer ;
begin
write('nhap do dai cua mang'); readln(n);
write('Nhap cac gia tri cua phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
for i:= 1 to n do
c) if i mod 2= 0 then write('Cac so chan cua mang la:',i);
d) if i mod 2= 1 then write('Cac so le cua mang la:',i);
readln
end.
Bài 1:
uses crt;
var n,kt,d,i:longint;
st:string;
begin
clrscr;
write('nhap n='); readln(n);
str(n,st);
kt:=0;
d:=length(st);
for i:=1 to d do
if (st[i]<>'4') and (st[i]<>'7') then kt:=1;
if kt=0 then write(n,' la so may man')
else write(n,' khong la so may man');
readln;
end.
program crtg;
uses crt;
var n,i, j: integer;
A: array[1..1000] of byte;
tb: integer;
min,max: byte;
begin
clrscr;
writeln('Nhap do dai day A: '); read(n);
writeln('Nhap cac phan tu cua day: ');
for i:=1 to n do
begin
writeln('a[',i,'] = ');
repeat
read(a[i]);
until a < 100;
end;
for i:= 1 to n do
begin
if a[i] <> 1 then
begin
j:= 2;
while (a[i] mod j <> 0) do j:=j+1;
if j = a[i] then write(a[i]',');
end;
end;
tb:=0;
for i:=1 to n do
tb:=tb+a[i];
tb:=tb/n;
writeln('Gia tri trung binh cua day tren la: ',tb);
max:=a[1]; min:=a[1];
for i:=2 to n do
begin
if a[i] < min then min:=a[i];
if a[i] > max then max:=a[i];
end;
writeln('Gia tri lon nhat cua day la ',max);
writeln('Gia tri nho nhat cua day la ',min);
readln
end.
uses crt;
var i,n ,dem:integer;
begin
clrscr;
Write( 'nhap so nguyen duong n: ');readln(n);
dem:=0;
for i:=1 to n do if n mod i = 0 then dem:=dem+1;
if(n<2) or (dem< >2) then writeln (n,' khong phai la so nguyen to')
else if dem=2 then writeln(n,' la so nguyen to');
readln
end.
program song_to;
uses crt;
var x,i,dem,tcs,t:longint;
function tongchuso(x:longint):longint;
begin
tcs:=0;
while x<>0 do
begin
tcs:=tcs+x mod 10;
x:=x div 10;
end;
tongchuso:=tcs;
end;
begin
clrscr;
write('nhap vao mot so:');readln(x);
dem:=0;
for i:=1 to x do
if x mod i=0 then dem:=dem+1;
if dem=2 then
begin
t:=0;
for i:=1 to tongchuso(x) do
if tongchuso(x) mod i =0 then t:=t+1;
if t=2 then write(x,' la so song to');
end
else write(x,' k la so song to');
readln;
end.
program KiemTraSoSieuNguyenTo;
uses crt;
function IsPrime(num: integer): boolean;
var
i: integer;
begin
if num < 2 then
IsPrime := false
else
begin
IsPrime := true;
for i := 2 to trunc(sqrt(num)) do
begin
if num mod i = 0 then
begin
IsPrime := false;
break;
end;
end;
end;
end;
function IsSuperPrime(num: integer): boolean;
var
i, temp: integer;
begin
IsSuperPrime := true;
while num > 0 do
begin
if not IsPrime(num) then
begin
IsSuperPrime := false;
break;
end;
temp := num mod 10;
num := num div 10;
end;
end;
var
n: integer;
inputFile, outputFile: text;
begin
assign(inputFile, 'SNT.INP');
assign(outputFile, 'SNT.OUT');
reset(inputFile);
rewrite(outputFile);
readln(inputFile, n);
if IsSuperPrime(n) then
writeln(outputFile, 1)
else
writeln(outputFile, 0);
close(inputFile);
close(outputFile);
end.
bạn viết tới phần mình chưa học á.bạn viết lại đơn giản hơn được không