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.
Câu 1:
uses crt;
var n,i,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
if n<2 then writeln(n,' khong la so nguyen to')
else begin
kt:=0;
for i:=2 to n-1 do
if n mod i=0 then kt:=1;
if kt=0 then writeln(n,' la so nguyen to')
else writeln(n,' khong la so nguyen to');
end;
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,max,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('So lon nhat la: ',max);
writeln('So nho nhat la: ',min);
readln;
end.
Program HOC24;
var i,n,d: integer;
a: array[1..1000] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
d:=0;
for i:=1 to n do if a[i] mod 5<>0 then d:=d+1;
write('Co ',d,' so khong chia het cho 5');
readln
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem1,dem2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i]>0 then inc(dem1);
if a[i]<0 then inc(dem2);
end;
writeln('So so nguyen duong la: ',dem1);
writeln('So so nguyen am la: ',dem2);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long b[1000],i,n,j,t,dem;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>b[i];
dem=0;
for (i=1; i<=n; i++)
{
t=0;
for (j=1; j<=b[i]/2; j++)
if (b[i]%j==0) t+=j;
if (t==b[i]) dem++;
}
cout<<dem;
return 0;
}
uses crt;
var a:integer;
begin
clrscr;
readln(a);
if a<0 then writeln(a,' la so am')
else if a>0 then writeln(a,' la so duong')
else writeln(a,' khong am cung khong duong');
readln;
end.
program im_14424;
uses crt;
var A:array[1..10] of integer;
i,n,biendem: integer;
begin
clrscr;
biendem:=0;
for i:=1 to 10 do
begin
write('Nhap vao',A[i],': ');
readln(A[i]);
if (A[i] mod 2 = 0) or (A[i] mod 2 = 1) then biendem:=biendem+1;
end;
write('So cac so nguyen la: ', biendem);
readln
end.
program hoc24;
n: string[20];
k,i,t,d,d1: byte;
code: integer;
begin
write('Nhap so K: '); readln(k);
write('Nhap so nguyen N: '); readln(n);
d:=0; d1:=0;
for i:=1 to k do
begin
val(n[i],t,code);
if t mod 2=0 then d:=d+1 else d1:=d1+1;
end;
writeln('Co ',d,' chu so chan');
write('Co ',d1,' chu so le');
readln
end.
uses crt;
var st:string;
dem,i,d:integer;
begin
clrscr;
write('st='); readln(st);
d:=length(st);dem:=0;
for i:=1 to d do
if st[i] in['0'..'9'] then inc(dem);
writeln(dem);
readln;
end.
Tham khảo bài anh Nguyễn Lê Phước Thịnh nhé
uses crt;
var st:string;
dem,i,d:integer;
begin
clrscr;
write('st='); readln(st);
d:=length(st);dem:=0;
for i:=1 to d do
if st[i] in['0'..'9'] then inc(dem);
writeln(dem);
readln;
end.