这是题目 A + B Again
这是源代码:
#include <stdio.h>
int main()
{
__int64 a,b;
while (scanf("%I64X %I64X",&a,&b)!=EOF)
{
if (a+b>=0)
printf("%I64X\n",a+b);
else
printf("-%I64X\n",0xFFFFFFFFFFFFFFFF-(a+b)+1);
}
return 0;
} /* 0xFFFFFFFFFFFFFFFF-(a+b)+1
#include <stdio.h>
int main ( )
{
__int64 a, b;
while ( scanf( "%I64X %I64X", &a, &b ) != EOF )
{
b += a;
if ( b < 0 )
{
b = -b;
a = '-';
}
else
a = 0;
if ( a)
putchar ( a );
printf ( "%I64X\n", b );
}
return 0;
}*/
刚开始提交一直错误,后来才明白是我的数据定义有点小。需要__int64才够,所以这样才提交正确。坚持就是胜利。