uses crt;
var n,nn,i,sum,count,cnt:longint;
function isPrimeNumber(n:longint):boolean;
var i:longint;
begin
if n < 2 then exit(false);
for i:=2 to trunc(sqrt(n)) do
if n mod i = 0 then exit(false);
exit(true);
end;
begin
clrscr;
readln(n);
nn:=n;
while n <> 0 do
begin
inc(sum,n mod 10);
inc(count);
if (n mod 10) mod 3 = 0 then inc(cnt);
n:=n div 10;
end;
writeln('So chu so: ',count);
writeln('Tong chu so: ',sum);
writeln('So chu so chia het 3: ',cnt);
write('Cac so nguyen to: ');
while nn <> 0 do
begin
if isPrimeNumber(nn mod 10) then write(nn mod 10,' ');
nn:=nn div 10;
end;
readln;
end.
program Hello;
uses crt;
var n,snt:string;
tong,i,a,d,sl:longint;
function nt(n:longint):boolean;
var i:longint;
begin
if n < 2 then exit(false);
for i:=2 to trunc(sqrt(n)) do
if n mod i = 0 then exit(false);
exit(true);
end;
procedure tinh;
begin
if n[1] = '-' then
begin
sl:= length(n) - 1;
delete(n,1,1);
end
else sl:= length(n);
for i:= 1 to length(n) do
begin
val(n[i],a);
tong:= tong + a;
if a mod 3 = 0 then inc(d);
if nt(a) = true then
snt:= snt + n[i] + ' ';
end;
end;
begin
readln(n);
tinh;
writeln('So chu so: ', sl);
writeln('Tong cac chu so: ', tong);
writeln('So chu so chia het cho 3: ', d);
writeln('Cac so nguyen to: ', snt);
readln;
end.
======================================
Một cách khác:
program Hello;
uses crt;
var n,snt:string;
tong,i,a,d,sl:longint;
procedure tinh;
begin
if n[1] = '-' then
begin
sl:= length(n) - 1;
delete(n,1,1);
end
else sl:= length(n);
for i:= 1 to length(n) do
begin
val(n[i],a);
tong:= tong + a;
if a mod 3 = 0 then inc(d);
if (a = 2) or (a = 3) or (a = 5) or (a = 7) then
snt:= snt + n[i] + ' ';
end;
end;
begin
readln(n);
tinh;
writeln('So chu so: ', sl);
writeln('Tong cac chu so: ', tong);
writeln('So chu so chia het cho 3: ', d);
writeln('Cac so nguyen to: ', snt);
readln;
end.
Tin học, tiếng Anh: informatics, tiếng Pháp: informatique, là một ngành khoa học chuyên nghiên cứu quá trình tự động hóa việc tổ chức, lưu trữ, xử lý và truyền dẫn thông tin của một hệ thống máy tính cụ thể hoặc trừu tượng (ảo). Với cách hiểu hiện nay, tin học bao hàm tất cả các nghiên cứu và kỹ thuật có liên quan đến việc mô phỏng, biến đổi và tái tạo thông tin.
Nguồn : Wikipedia - Bách khoa toàn thưLớp 8 - Năm thứ ba ở cấp trung học cơ sở, học tập bắt đầu nặng dần, sang năm lại là năm cuối cấp áp lực lớn dần nhưng các em vẫn phải chú ý sức khỏe nhé!
Nguồn : ADMIN :))Xem thêm tại https://loigiaisgk.com/cau-hoi or https://giaibtsgk.com/cau-hoi
Copyright © 2021 HOCTAPSGK