/*******************************************************************
** HighlightCodeV3.2 software by yzfy(雨中飞燕) http:// **
*******************************************************************/
#include "stdio.h"
#include "string.h"
#define MAX_STR_LEN 205
#define MAX_INT 1000000000
char a[MAX_STR_LEN + 9], b[MAX_STR_LEN + 9];
int na[MAX_STR_LEN/3+3], nb[MAX_STR_LEN/3+3], nc[MAX_STR_LEN/3+3];
int nmap[16][16][16], *pmap=(int*)nmap;
void Init()
{
for (int a=0; a<=9; ++a)for (int b=0; b<=9; ++b)
for (int c=0; c<=9; ++c)nmap[a][b][c] = a*100+b*10+c;
}
#define GetVal(a,b,c) pmap[((a<<4)+b<<4)+c]
void Str2BInt(int* na, char* a)
{
char* pa=a+8;
int al = strlen(pa), n;
for (n=0; n<al; n+=4) *((int*)(pa+n)) -= '0000';
*((int*)(pa+n)) -= '0000';
for (n=1, pa+=al-9; pa>=a; pa-=9,++n)
{
na[n] = GetVal(*pa, pa[1], pa[2])*1000000
+ GetVal(pa[3], pa[4], pa[5])*1000 + GetVal(pa[6], pa[7], pa[8]);
}
na[n] = 0;
na[0] = n-1;
}
int* Calc()
{
Str2BInt(na, a);
Str2BInt(nb, b);
int *pa=na, *pb=na;
int ns = na[0]>nb[0]?(pb=nb,nb[0]):(pa=nb,na[0]);
int n=1;
for ( ; n<=ns; ++n)
{
pa[n] += pb[n];
if (pa[n]>=MAX_INT)
{
pa[n] -= MAX_INT;
++pa[n+1];
}
}
for ( ; pa[n]>=MAX_INT; ++n)
{
pa[n] -= MAX_INT;
++pa[n+1];
}
if (pa[n]==0) --n;
if (n>pa[0]) pa[0]=n;
return pa;
}
int Input()
{
return gets(a+8) && gets(b+8);
}
void Output(int* p)
{
int n = p[0];
printf("%d", p[n]);
for (--n; n>0; --n) printf("%09d", p[n]);
putchar('\n');
}
int main()
{
Init();
while (Input())
{
int*p;
p = Calc();
Output(nc);
}
return 0;
}
你这个程序能正确运行???????????????????
你确定Output(nc);这一句没有写错?