-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFun9.java
More file actions
22 lines (21 loc) · 574 Bytes
/
Fun9.java
File metadata and controls
22 lines (21 loc) · 574 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package fun;
public class Fun9 {
public static void main(String[] args) {
System.out.println (AddRightDigit (10, 2));//210
System.out.println (AddRightDigit (1, 2));//21
System.out.println (AddRightDigit (123, 2));//2123
System.out.println (AddRightDigit (1231, 2));//21231
}
public static int AddRightDigit(int k,int r){
int rk=0;
int t=k;
if ( 1<=r && r <=9 ){
while (t>0){
r*=10;
t/=10;
}
rk=r+k;
}
return rk;
}
}