Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int a, b, r1, r2, r3=0, sum, ct;
  5.     while(scanf("%d%d",&a,&b)==2){
  6.             if(a==0 && b==0){
  7.                 break;
  8.             }
  9.             sum=0;
  10.             ct=0;
  11.             r3=0;
  12.         while(a!=0 && b!=0){
  13.             r1=a%10;
  14.             r2=b%10;
  15.             sum=r1+r2+r3;
  16.             r3=0;
  17.             if(sum>9){
  18.                     ct++;
  19.                 while(sum!=0){
  20.                     r3=sum%10;
  21.                     sum/=10;
  22.                 }
  23.             }
  24.             a/=10;
  25.             b/=10;
  26.         }
  27.         if(ct==0){
  28.             printf("No carry operation.\n");
  29.         }
  30.         else{
  31.             printf("%d carry operations.\n",ct);
  32.         }
  33.     }
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement