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.
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.
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.
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.
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.
#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;
}
program Min;
uses crt;
var i,n:integer;
begin
clrscr;
write('Nhap n: '); readln(n);
write('Cac so le nho hon hoac bang ',n,'la :');
for i:=1 to n do if i mod 2 = 1 then write(i:4);
readln
end.
Var i,n,dem:integer;
begin
write('Nhap n = ');readln(n);
for i:=1 to n do
if n mod i = 0 then dem:=dem+1;
if dem=2 then write(n,' la so nguyen to')
else write(n,' khong la so nguyen to');
readln;
end.
program BangCuuChuong;
var
N, i, j: integer;
IsEven: boolean;
IsPrime: boolean;
begin
write('Nhap N (0 < N < 10): ');
readln(N);
// Kiểm tra N có phải số chẵn hay lẻ
IsEven := (N mod 2 = 0);
if IsEven then
writeln(N, ' la so chan')
else
writeln(N, ' la so le');
// Kiểm tra N có phải số nguyên tố hay không
IsPrime := true;
if (N < 2) then
IsPrime := false
else
for i := 2 to trunc(sqrt(N)) do
if (N mod i = 0) then
begin
IsPrime := false;
break;
end;
if IsPrime then
writeln(N, ' la so nguyen to')
else
writeln(N, ' khong la so nguyen to');
// In ra bảng cửu chương N
writeln('Bang cuu chuong ', N, ':');
for i := 1 to 10 do
begin
j := i * N;
writeln(N, ' x ', i, ' = ', j);
end;
readln;
end.
Mấy cái phần mình gạch // là giải thích phần code đó làm gì nha.
Program HOC24;
var i,n,d: byte;
begin
write('Nhap N: '); readln(n);
writeln('Bang cuu chuong ',n,' : ');
for i:=1 to 10 do writeln(n,' x ',i,' = ',n*i);
if n mod 2=0 then writeln(n,' la so chan ') else writeln(n,' la so le');
d:=0;
for i:=1 to n do if n mod i=0 then d:=d+1;
if d=2 then write(n,' la so nguyen to') else write(n,' khong phai la so nguyen to');
readln
end.
{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.
}
c:
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]%2==0) cout<<a[i]<<" ";
return 0;
}
d:
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
nn=a[1];
for (i=1; i<=n; i++) nn=min(nn,a[i]);
cout<<nn;
return 0;
}
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.
câu c bạn viết cách ra nhé!