Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int circular(int a,int b)
- {
- int nr=a;
- int p=1;
- int k=0;
- while(nr)
- {
- k++;
- p*=10;
- nr=nr/10;
- }
- p/=10;
- for(int i=1; i<=k; i++)
- {
- if(a==b)
- {
- return i-1;
- }
- else
- {
- int x=a%10;
- a=x*p+a/10;
- }
- }
- return -1;
- }
- int main()
- {
- cout<<circular(120362,621203);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement