| ||||||||||
| 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 a[100],b[100];
int l1,l2;
int i,j,t;
int c[100],d[100],e[100];
while(scanf("%s %s",a,b)==2)
{
int count=0;
if(a[0]=='0'&&b[0]=='0') break;
l1=strlen(a);
l2=strlen(b);
memset(c,0,sizeof(c));
memset(d,0,sizeof(d));
memset(e,0,sizeof(e));
for(i=l1;i>=0;i--)
c[i]=a[i]-'0';
for(j=l2;j>=0;j--)
d[i]=b[i]-'0';
if(l1>l2) t=l2;
else t=l1;
for(i=t-1;i>=0;i--)
{
e[i]+=d[i]+c[i];
if(e[i]>=10)
{
e[i]-=10;
e[i+1]++;
count++;
}
}
if(count==0)
printf("No carry operation.\n");
else if(count==1)
printf("1 carry operation.\n");
else
printf("%d carry operation.",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