- 记数问题
- 2016-09-27 21:26:05 @
1.
program ex6;
var n:longint;
x,i,j,t:integer;
s1:string;
sum,code:integer;
begin
readln(n,x);
t:=0;
sum:=0;
for i:=1 to n do
begin
str(i,s1);
for j:=1 to length(s1) do
begin
val(s1[j],t,code);
if t=x then sum:=sum+1;
end;
end;
writeln(sum);
end.
2.
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.
3.
program ex6;
var n:longint;
x,i,j:integer;
s1:string;
a:array[0..9] of longint;
begin
readln(n,x);
for i:=1 to n do
begin
str(i,s1);
for j:=1 to length(s1) do
a[ord(s1[j])-ord('0')]:=a[ord(s1[j])-ord('0')]+1;
end;
writeln(a[x]);
end.
3 条评论
-
13393881576 LV 4 @ 2016-12-13 20:30:58
var i,j,k,n,t:longint;
begin
read(i,j);
for k:=1 to i do
begin
t:=k;
while t<>0 do
begin
if t mod 10=j then inc(n);
t:=t div 10;
end;
end;
write(n);
end. -
2016-09-28 09:29:58@
var n,x,y,i,j,m,d:longint;
b:string;
begin
readln(n,x);
y:=0;
for i:=1 to n do
begin
m:=i;
str(i,b);
for j:=1 to length(b) do
begin
d:=m mod 10;
if d=x then y:=y+1;
m:=m div 10;
end;
end;
write(y);
end. -
2016-09-28 09:29:55@
var n,x,y,i,j,m,d:longint;
b:string;
begin
readln(n,x);
y:=0;
for i:=1 to n do
begin
m:=i;
str(i,b);
for j:=1 to length(b) do
begin
d:=m mod 10;
if d=x then y:=y+1;
m:=m div 10;
end;
end;
write(y);
end.
- 1
信息
- ID
- 1848
- 难度
- 5
- 分类
- (无)
- 标签
- 递交数
- 16586
- 已通过
- 5810
- 通过率
- 35%
- 被复制
- 36
- 上传者