Guest User

Untitled

a guest
Apr 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. //#include <conio.h>
  4. int abc(int a)
  5. {
  6.   if (a<=0)
  7.     return (-a);
  8.  
  9.   else
  10.  
  11.     return a;
  12. }
  13. int power(int p){
  14.   int cd=0;
  15.   int i=0;
  16.   for(i=0;i<=p;i++)
  17.     {
  18.       cd*=10;
  19.     }
  20.   return cd;
  21. }
  22. int main()
  23. {
  24.   int res1,res2,n=1,digit2,digit1,num,l,m,k;
  25.  
  26.   while (scanf("%d", &num)==1){
  27.    
  28.     l=power(n);
  29.     res1=num %l;
  30.     if (res1==num)
  31.       {
  32.     break;
  33.       } else { n++;}
  34.   }
  35.   while (1){
  36.     if (n==1)
  37.       { res1=num %l;
  38.     printf("%d", res1);
  39.       } else {
  40.       l=power(n);
  41.       m=power(n);
  42.       k=power(n-1);
  43.       res1=num %l;
  44.       res2=res1/(power(n-1));
  45.       digit1=res2;
  46.       n--;
  47.       res1=num % m;
  48.       res2=res1 % k;
  49.       digit2=res2;
  50.       n--;
  51.       printf("%d%d%d\n", abc(digit1-digit2),digit1,digit2);
  52.     }
  53.                        
  54.   }    
  55.   return 0;
  56. }
Add Comment
Please, Sign In to add comment