| ||||||||||
| 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 | |||||||||
哪位好心人帮我看看究竟错哪#include<stdio.h>
#include<string.h>
int main()
{
char m[12];
char n[12];
char f[12];
int a,b,s,p,t;
while(scanf("%s %s",m,n)!=EOF)
{
if(strcmp(m,"0")==0&&strcmp(n,"0")==0)
break;
a=strlen(m);
b=strlen(n);
s=0;
if(a<b)
{
strcpy(f,m);
strcpy(m,n);
strcpy(n,f);
t=a;
a=b;
b=t;
}
while(a>=0&&b>=0)
{
a--;
b--;
if((m[a]+n[b]-96)>=10)
{
s++;
m[a-1]++;
if(m[a-1]-48>=10)
{
p=a-1;
while(m[p]-48>=10)
{
s++;
m[p]=m[p]-10;
m[p-1]++;
p=p-1;
}
}
}
}
if(s==0)
printf("No carry operation.\n");
else
if(s==1)
printf("1 carry operation.\n");
else
printf("%d carry operations.\n",s);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator