-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo6.java
89 lines (88 loc) · 1.29 KB
/
demo6.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import java.util.*;
class demo6{
public static void main(String sz[])
{
int r1,r2,f=0;
Scanner ob=new Scanner(System.in);
int a=ob.nextInt();
r1=ob.nextInt();
r2=ob.nextInt();
String s;
int b=0;
int z=0;
Scanner ob1=new Scanner(System.in);
do
{
z=0;
s=ob1.nextLine();
if(s.charAt(0)=='A')
{
for(int i=r1;i<=r2;i++)
{
if(i>100)
{
int k=i;
f=0;
do
{
if(((k%10)+48)==s.charAt(1))
{
k=(k/100);
}
else
{
f=1;
break;
}
}while(k>0);
if(f==0)
{
z++;
}
}
}
System.out.println(z);
}
else if(s.charAt(0)=='C')
{
for(int i=r1;i<=r2;i++)
{
int k=i;
int c=0;
while(k>0)
{
if(((k%10)+48)==s.charAt(2))
{
c++;
}
else
{
c=0;
}
k=k/10;
if((c+48)>=s.charAt(1))
{
z++;
break;
}
}
}
System.out.println(z);
}
else if((s.charAt(0)>=48&&s.charAt(0)<=57))
{
for(int i=r1;i<=r2;i++)
{
int k=i;
int r=(int)(k/Math.pow(10,(s.length()-1)))+48;
if(r==s.charAt(0)&&i<=Math.pow(10,(s.length())))
{
z++;
}
}
System.out.println(z);
}
b++;
}while(b<a);
}
}