-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrotate.java
More file actions
35 lines (33 loc) · 796 Bytes
/
rotate.java
File metadata and controls
35 lines (33 loc) · 796 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
import java.util.Scanner;
public class rotate
{
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int k = scn.nextInt();
rotatenum(n, k);
scn.close();
}
public static void rotatenum(int n, int k)
{
int temp = n;
int count = 0;
while(n>0)
{
n = n/10;
count++;
}
if (k>count){
k = k%count;
}
if (k<0){
k = count+k;
}
double div = Math.pow(10,k);
int qut = (int)(temp/div);
int rem = (int)(temp%div);
int num = rem*((int)Math.pow(10, count-k));
int newnum = num + qut;
System.out.println(newnum);
}
}