- 记数问题
- 2016-09-27 21:06:48 @
program ex6;
var n:longint;
x,i,j:integer;
s1:string;
sum:longint;
ch:char;
begin
readln(n,x);
ch:=chr(ord('0')+x);
sum:=0;
for i:=1 to n do
begin
str(i,s1);
for j:=1 to length(s1) do
if ch=s1[j] then sum:=sum+1;
end;
writeln(sum);
end.
1 条评论
-
什么鬼 LV 6 @ 2017-02-07 13:42:40
i 要循环到 n 呀
代码:
program ex6;
var
n,i:longint;
x,j:integer;
s1:string;
sum:longint;
ch:char;
begin
readln(n,x);
ch:=chr(ord('0')+x);
sum:=0;
for i:=1 to n do
begin
str(i,s1);
for j:=1 to length(s1) do
if ch=s1[j] then sum:=sum+1;
end;
writeln(sum);
end.
- 1
信息
- ID
- 1848
- 难度
- 5
- 分类
- (无)
- 标签
- 递交数
- 16558
- 已通过
- 5790
- 通过率
- 35%
- 被复制
- 36
- 上传者