#include<stdio.h>
#include<string.h>
int main(){
char a[11],b[11];
while(scanf("%s%s",&a,&b)!=EOF){
if(strcmp(a,"0")==0&&strcmp(b,"0")==0) break;
int ans=0;
int len1=strlen(a);
int len2=strlen(b);
int i,j;
i=len1-1;j=len2-1;
int remainder=0;
while(i>=0&&j>=0){
if(a[i]-'0'+b[j]-'0'+remainder>=10){
ans++;
remainder=(a[i]-'0'+b[j]-'0'+remainder)/10;
}
i--;
j--;
}
if(ans==0) printf("NO carry operation.\n");
else if(ans==1) printf("%d carry operation.\n",ans);
else printf("%d carry operations.\n",ans);
}
return 0;
}
/**************************************************************
Problem: 1143
User: cust123
Language: C++
Result: Accepted
Time:0 ms
Memory:1020 kb
****************************************************************/
题目1143:Primary Arithmetic
最新推荐文章于 2018-09-20 19:28:35 发布