(UVA)10035-carry


#include <stdio.h>

int main(){

 int a = 0, b = 0;

while ((scanf("%d%d", &a, &b)) != EOF) {

  int n = 0, count = 0, c = 0;

  if (a == 0 && b == 0)  break;

  while (a != 0 || b != 0) {

    c += (a % 10) + (b % 10);

    c = c / 10;

    if (c == 1) count++;

    a /= 10;

    b /= 10;

   }

   if (count == 1) printf("1 carry operation.\n");

   else if (count>1) printf("%d carry operations.\n", count);

    else  printf("No carry operation.\n");

  }

 return 0;

}

留言

這個網誌中的熱門文章

Bundle Adjustment 光束平差法

Structure From Motion