Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
1254
1142
const fi='lo.inp';
fo='lo.out';
var a:ansistring;
dem:longint;
procedure so;
var i:longint;
begin
for i:=1 to length(a) do
begin
if a[i]='0' then inc(dem);
if a[i]='4' then inc(dem);
if a[i]='6' then inc(dem);
if a[i]='9' then inc(dem);
if a[i]='8' then inc(dem,2);
end;
end;
begin
assign(input,fi);
reset(input);
read(a);
close(input);
assign(output,fo);
rewrite(output);
so;
write(dem);
close(output);
end.
Hãy giúp mọi người biết câu trả lời này thế nào?
2378
1794
uses crt;
var s:string; n,i,dem:longint; d:text;
begin
clrscr;
assign(d,'input.pas');reset(d);
readln(d,n); str(n,s);
close(d);
assign(d,'output.pas');rewrite(d);
for i:=1 to length(s) do
if (s[i]='0')or(s[i]='4')or(s[i]='6')or(s[i]='9') then inc(dem) else
if s[i]='8' then inc(dem,2);
writeln(d,dem);
close(d);
end.
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin