| ||||||||||
| 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 | |||||||||
不ac 帮忙看下 谢谢#include<stdio.h>
#include<string.h>
int main()
{
char a[4][11];
int yu,count,lon1,lon2,n,lon;
while(scanf("%s%s",a[0],a[1]),(a[0][0]!='0' || a[1][0]!='0' || a[0][1] || a[1][1]))
{
count=0;
yu=0;
lon1=strlen(a[0]);
for(n=0;n<lon1;n++)
strcpy(&a[2][10-n],&a[0][lon1-1-n]);
for(n=0;n<11-lon1;n++)
a[2][n]='0';
lon2=strlen(a[1]);
for(n=0;n<lon2;n++)
strcpy(&a[3][10-n],&a[1][lon2-1-n]);
for(n=0;n<11-lon2;n++)
a[3][n]='0';
if(lon1>lon2)
lon=lon1;
else
lon=lon2;
for(n=0;n<lon;n++)
{
if(a[2][10-n]+a[3][10-n]+yu-'0'*2>9)
{
count++;
yu=1;
}
else
yu=0;
}
if(count==0)
printf("No carry operation.\n");
else if(count==1)
puts("1 carry operation.");
else
printf("%d carry operations.\n",count);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator