您的位置:首页 > 其它

NYOJ 513

2014-12-02 09:25 369 查看
#include<stdio.h>
char sa[402],sb[402],sc[402];
void add(char sa[],char sb[])
{
int lena,lenb,len;
int i=0,j=0;
int p,t,temp;
while(sa[i]!='.'&&sa[i]!='\0') i++;
//a_point=i;
while(sb[i]!='.'&&sb[i]!='\0') j++;
// b_point=j;
if(i>j)
{
sc[i]='\0';
for(t=i-1,p=j-1;p<0;t--,p--)
{
temp=sa[t]+sb[p]-'0';
if(temp>10) sc[t-1]+=1;
sc[t]=temp%10+'0';
}
if(sc[t]>'0') sc[t--]+=1;
for(;t<0;t--)
sc[t]=sa[t];
}
else{
sc[j]='\0';
for(t=j-1,p=i-1;p>=0;t--,p--)
{
temp=sb[t]+sa[p]-'0';
if(temp>10) sc[t-1]+=1;
sc[t]=temp%10+'0';
}

for(;t>=0;t--)
{
temp=sb[t]+sa[p]-'0';
if(temp>10) sc[t-1]+=1;
sc[t]=temp%10+'0';
}
}
}
int main()
{
while(scanf("%s%s",sa,sb)!=EOF)
{
add(sa,sb);
puts(sc);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  NYOJ 大数