pascal 计算在1 到n 的所有整数中,数字x(0 ≤ x ≤ 9)共出现了多少次?
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/24 09:21:55
pascal 计算在1 到n 的所有整数中,数字x(0 ≤ x ≤ 9)共出现了多少次?
pascal
pascal
var i,j,n,a,x:longint;
s,q:string;
begin
assign(input,'count.in');
assign(output,'count.out');
reset(input);
rewrite(output);
read(n,x);
a:=0;
str(x,q);
for i:=1 to n do begin
str(i,s);
for j:=1 to length(s) do
if s[j]=q then inc(a);
end;
writeln(a);
close(input);
close(output);
end.
s,q:string;
begin
assign(input,'count.in');
assign(output,'count.out');
reset(input);
rewrite(output);
read(n,x);
a:=0;
str(x,q);
for i:=1 to n do begin
str(i,s);
for j:=1 to length(s) do
if s[j]=q then inc(a);
end;
writeln(a);
close(input);
close(output);
end.
在1、2、3、……到132这些数中,数字“1”共出现了多少次?
一本故事书共121页,在这本书的页码中数字1共出现了多少次?
1到1000000的所有自然数中0总共出现了多少次?
在1-100的奇数中,数字3一共出现了多少次?所有单数的和是多少?
在1、2、3、.、132这些数中,数字"1"共出现了多少次?
在1~100这100个数中,数字5共出现了多少次?写出数.
N为正整数,计算从1到N的所有整数中包含数字1的个数.
在1到200中,数字6一共出现多少次?
1-100这些数中,“9”这个数字共出现了多少次?
在1到600这600个自然数中,数字“2”出现了多少次?
在1到400自然数中,数字8出现了多少次?
一本科幻小说共300页:问:编印这本小说的页码共用了多少个数字 数字0在页码中出现了多少次