-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcountzeros
More file actions
38 lines (34 loc) · 711 Bytes
/
Copy pathcountzeros
File metadata and controls
38 lines (34 loc) · 711 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
// by stack falling return type
public class test2{
public static int numbercount(int n) {
if(n==0) {
return 0;
}
if(n%10==0) {
return 1+ numbercount(n/10);
}
else {
return numbercount(n/10);
}
}
public static void main(String[] args) {
int result= numbercount(1020300);
System.out.println(result);
}
}
// by stack building void
public class countzero {
public static void count(int num,int zeros) {
if(num==0) {
System.out.println("the num of zeroes:"+zeros);
return;
}
if(num%10==0) {
zeros++;
}
count(num/10,zeros);
}
public static void main(String[] args) {
count(108002,0);
}
}