-
Notifications
You must be signed in to change notification settings - Fork 0
/
Problem_6_2.c
51 lines (41 loc) · 901 Bytes
/
Problem_6_2.c
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
// cyclic number verification
// verify the given number is cyclic or not
// Input Format
// Num1 num2
// Constraints
// 1<=range<=9999999999
// Sample Input 1
// 12345 45123
// Sample Output 1
// Yes
// Sample Input 2
// 12345 54123
// Sample Output 2
// No
#include <stdio.h>
int main() {
long long int numberOne, numberTwo, rotated;
int power = 1, degree = 0;
system("cls");
printf("\nEnter no 1 : ");
scanf("%lld",&numberOne);
printf("\nEnter no 2 : ");
scanf("%lld",&numberTwo);
while(numberOne / power) {
degree++;
power *= 10;
}
power /= 10;
rotated = numberOne;
while(rotated != numberTwo && degree != 0)
{
rotated = (rotated % 10) * power + (rotated / 10);
degree--;
}
if(rotated == numberTwo) {
printf("\nYes");
} else {
printf("\nNo");
}
return 0;
}