-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution17.java
More file actions
39 lines (36 loc) · 865 Bytes
/
Copy pathsolution17.java
File metadata and controls
39 lines (36 loc) · 865 Bytes
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
package nowcoder;
public class solution17 {
public void print1toMaxofdigit(int n)
{
if(n < 0)
{
return;
}
char[] number = new char[n];
print1toMaxofdigit(number,0);
}
private void print1toMaxofdigit(char[] number, int digit) {
if(digit == number.length)
{
printNumber(number);
return;
}
for(int i = 0;i<10;i++)
{
number[digit] = (char) (i+'0');
print1toMaxofdigit(number,digit+1);
}
}
private void printNumber(char[] number) {
int index = 0;
while(index<number.length&& number[index] =='0')
{
index++;
}
while(index<number.length)
{
System.out.println(number[index++]);
}
System.out.println();
}
}