UVa10035 小學生算數(Primary Arithmetic)
阿新 • • 發佈:2017-10-06
es2017 primary rim std com 學生 -a one ide
1 #include<cstdio> 2 int main() 3 { 4 int a,b; 5 while(scanf("%d%d",&a,&b)==2) 6 { 7 if(a==0 && b==0) break; 8 int c=0, ans=0; 9 while(a!=0 || b!=0) 10 { 11 c = (a%10 + b%10 +c) > 9 ? 1:0; 12 ans += c;View Code13 a/=10; b/=10; 14 } 15 if(ans>1) printf("%d carry operations.\n",ans); 16 else if(ans==1) printf("1 carry operation.\n"); 17 else printf("No carry operation.\n"); 18 } 19 return 0; 20 }
UVa10035 小學生算數(Primary Arithmetic)