Advertisement
madidino

teza9-sub3-1

Nov 20th, 2023
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int circular(int a,int b)
  5. {
  6.     int nr=a;
  7.     int p=1;
  8.     int k=0;
  9.     while(nr)
  10.     {
  11.         k++;
  12.         p*=10;
  13.         nr=nr/10;
  14.     }
  15.     p/=10;
  16.     for(int i=1; i<=k; i++)
  17.     {
  18.         if(a==b)
  19.         {
  20.             return i-1;
  21.         }
  22.         else
  23.         {
  24.             int x=a%10;
  25.             a=x*p+a/10;
  26.         }
  27.     }
  28.     return -1;
  29. }
  30. int main()
  31. {
  32.     cout<<circular(120362,621203);
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement