Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- //#include <conio.h>
- int abc(int a)
- {
- if (a<=0)
- return (-a);
- else
- return a;
- }
- int power(int p){
- int cd=0;
- int i=0;
- for(i=0;i<=p;i++)
- {
- cd*=10;
- }
- return cd;
- }
- int main()
- {
- int res1,res2,n=1,digit2,digit1,num,l,m,k;
- while (scanf("%d", &num)==1){
- l=power(n);
- res1=num %l;
- if (res1==num)
- {
- break;
- } else { n++;}
- }
- while (1){
- if (n==1)
- { res1=num %l;
- printf("%d", res1);
- } else {
- l=power(n);
- m=power(n);
- k=power(n-1);
- res1=num %l;
- res2=res1/(power(n-1));
- digit1=res2;
- n--;
- res1=num % m;
- res2=res1 % k;
- digit2=res2;
- n--;
- printf("%d%d%d\n", abc(digit1-digit2),digit1,digit2);
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment