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,s,t;
- int co,sum,carry;
- while( scanf("%lld %lld",&n,&m) == 2)
- {
- if(n == 0 && m == 0)
- {
- break;
- }
- carry = 0;
- co = 0;
- for(; n%10 != 0 || m%10 != 0;)
- {
- s = n%10;
- t = m%10;
- sum = s + t + carry;
- n = n/10;
- m = m/10;
- if(sum<10)
- {
- carry = 0;
- continue;
- }
- else
- {
- co = co + 1 ;
- carry = sum/10;
- }
- }
- if( co == 0)
- {
- printf("No carry operation.\n");
- }
- else if(co == 1)
- {
- printf("%d carry operation.\n",co);
- }
- else
- {
- printf("%d carry operations.\n",co);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement