Saleh127

Untitled

May 3rd, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include<stdio.h>
  2. long long carry(long long a,long long b)
  3. {
  4. long long c,d,k,l;
  5. k=0;
  6. l=0;
  7. while(1)
  8. {
  9. c=a%10;
  10. d=b%10;
  11. a=a/10;
  12. b=b/10;
  13. if((c+d+k)>=10)
  14. {
  15. l++;
  16. k=1;
  17. }
  18. else k=0;
  19. if(a==0 && b==0) break;
  20. }
  21. return l;
  22. }
  23. int main()
  24. {
  25. long long i,j,e,f;
  26. while(1)
  27. {
  28. scanf("%lld %lld",&i,&j);
  29. if(i==0 && j==0) break;
  30. e = carry(i, j);
  31. if(e==0)
  32. printf("No carry operation.\n");
  33. else if(e==1)
  34. printf("1 carry operation.\n");
  35. else
  36. printf("%lld carry operations.\n",e);
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment