| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求救,为什么啊WA#include<stdio.h>
#define MAX 12
void main(){
long a,b,c[MAX]={0},d[MAX]={0};
scanf("%ld%ld",&a,&b);
while(a!=0&&b!=0){
int i=0,totol=0,mid=0;
if(a==0||b==0)
printf("No carry operation.\n");
else{
if(a<0)
mid+=1;
if(b<0)
mid+=1;
if(mid==1)
printf("No carry operation.\n");
else{
a=a>0?a:-a;
b=b>0?b:-b;
while(a>0){
c[i]=a%10;
a=a/10;
i=i+1;
}
i=0;
while(b>0){
d[i]=b%10;
b=b/10;
i=i+1;
}
for(i=0;i<MAX;i++){
if(c[i]+d[i]>=10){
c[i+1]+=1;
totol+=1;
}
c[i]=0;d[i]=0;
}
if(totol==0)
printf("No carry operation.\n");
else if(totol==1)
printf("1 carry operation.\n");
else
printf("%d carry operations.\n",totol);
}
}
scanf("%ld%ld",&a,&b);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator