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.
const
nhap='bai1.inp';
xuat='bai1.out';
var n,m,u,d:int64;
begin
assign(input,nhap);reset(input);
assign(output,xuat);rewrite(output);
read(n);
while n<>0 do
begin
m:=n mod 10;
n:=n div 10;
if (m=1) or (m=2) or (m=3) or (m=5) or
(m=7) then d:=0;
if (m=0) or (m=4) or (m=6) or (m=9)
then d:=1;
if m=8 then d:=2;
u:=u+d;
end;
writeln(u);
close(input);close(output);
end.
uses crt;
var n,d,dem,i,x,y,t:integer;
st:string;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (1000<=n) and (n<=9999);
if n mod 2=0 then
begin
str(n,st);
d:=length(st);
dem:=0;
for i:=1 to d do
begin
val(st[i],x,y);
if x=0 then inc(em);
end;
writeln('So chu so 0 co trong so ',n,' la: ',dem);
end
else begin
str(n,st);
t:=0;
d:=length(st);
for i:=1 to d do
begin
val(st[i],x,y);
t:=t+sqr(x);
end;
writeln('Tong binh phuong cac chu so trong so ',n,' la: ',t);
end;
readln;
end.
uses crt;
var n,d,dem,i,x,y,t:integer;
st:string;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (1000<=n) and (n<=9999);
if n mod 2=0 then
begin
str(n,st);
d:=length(st);
dem:=0;
for i:=1 to d do
begin
val(st[i],x,y);
if x=0 then inc(em);
end;
writeln('So chu so 0 co trong so ',n,' la: ',dem);
end
else begin
str(n,st);
t:=0;
d:=length(st);
for i:=1 to d do
begin
val(st[i],x,y);
t:=t+sqr(x);
end;
writeln('Tong binh phuong cac chu so trong so ',n,' la: ',t);
end;
readln;
end.
Tớ không hiểu.
Số may mắn là số gì?
6 = 3 + 2 + 1 hay sao?
Bài 1:
Program HOC24;
var x,t: byte;
begin
write('Nhap so co 2 chu so: '); readln(x);
t:=(x mod 10)+(x div 10);
write('Tong 2 chu so cua so do la: ',t);
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.
const
fi='lhcs.inp';
fo='lhcs.out';
a:array[0..9] of byte=(1,0,0,0,1,0,1,0,2,1);
var
f:text;
t,n:integer;
procedure inp;
begin
assign(F,fi);
reset(F);
read(f,n);
close(F);
end;
procedure out;
begin
assign(f,fo);
rewrite(F);
t:=0;
while n<>0 do
begin
t:= t+a[n mod 10];
n:= n div 10
end;
write(f,t);
close(F);
end;
BEGIN
INP;
OUT;
END.
const
fi='lohongcs.inp';
fo='lohongcs.out';
var
f:text;
i,s:integer;
n:longint;
a:array[0..9] of byte;
begin
assign(f,fi);
reset(f);
read(f,n);
for i:= 1 to n do
read(f,a[i]);
a[8]:=2;
a[0]:=1; a[4]:=1; a[6]:=1; a[9]:=1;
a[1]:=0; a[2]:=0; a[3]:=0; a[5]:=0; a[7]:=0;
close(F);
assign(f,fo);
rewrite(F);
s:=0;
repeat
i:=n mod 10;
s:=s+a[i];
n :=n div 10 ;
until n=0;
write(f,s);
close(F);
end.