Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<stdlib.h>
- int main()
- {
- long long n,m,temp,tem,d,c,stemp,sum,sumTemp,sd,carry;
- while(1)
- {
- scanf("%lld %lld",&n,&m);
- if(n == 0 && m == 0)
- {
- break;
- }
- if( n > m)
- {
- tem = n;
- n = m;
- m = tem;
- }
- temp = m;
- stemp = n;
- carry = 0;
- sd = 0;
- while( temp != 0)
- {
- d = temp%10;
- c = stemp%10;
- temp = temp/10;
- stemp = stemp/10;
- d = d + sd;
- sum = d + c;
- if(sum<10)
- {
- continue;
- }
- else
- {
- sumTemp = sum;
- while( sumTemp != 0 )
- {
- sd = sumTemp%10;
- sumTemp = sumTemp /10;
- }
- carry++;
- }
- }
- if( carry == 0)
- {
- printf("No carry operation.\n");
- }
- else if(carry == 1)
- {
- printf("1 carry operation.\n");
- }
- else
- {
- printf("%lld carry operations.\n",carry);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement