A+B Problem Time Limit:1Sec Input File:aplusb.in Calculate a+bInputthe input will consist of a series of pairs of integers a and b,separated by one line.Each integar may consist of less than 79 digits.Output For each pair of input integers a and byou

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/29 01:24:42
A+BProblemTimeLimit:1SecInputFile:aplusb.inCalculatea+bInputtheinputwillconsistofaseriesofpairsofint

A+B Problem Time Limit:1Sec Input File:aplusb.in Calculate a+bInputthe input will consist of a series of pairs of integers a and b,separated by one line.Each integar may consist of less than 79 digits.Output For each pair of input integers a and byou
A+B Problem Time Limit:1Sec Input File:aplusb.in Calculate a+b
Input
the input will consist of a series of pairs of integers a and b,separated by one line.Each integar may consist of less than 79 digits.
Output
For each pair of input integers a and byou should output the sum of a and b in one line.
这是钱能C++程序设计第二版第十一章的课后题,意思是输出两个最多79位的整数的和,希望各位大神能提供一些想法和源代码.
附上原题图片,

A+B Problem Time Limit:1Sec Input File:aplusb.in Calculate a+bInputthe input will consist of a series of pairs of integers a and b,separated by one line.Each integar may consist of less than 79 digits.Output For each pair of input integers a and byou
//DEV CPP编译通过~
#include
#include
#include
#define MAX_SIZE 100 // 最大位数
char n1[MAX_SIZE] = ""; // 第一个整数
char n2[MAX_SIZE] = ""; // 第二个整数
char n3[MAX_SIZE+1] = ""; // 两个整数之和
void do_sum();
int main(void)
{
//读取两个整数
printf("第一个整数为:");
scanf("%s", n1);
printf("第二个整数为:");
scanf("%s", n2);
do_sum();//求和
FILE *fp;
if((fp=fopen("aplusb.in","w"))==NULL)//保存结果
{
fprintf(stderr,"不能打开文件.\n");
exit(1);
}
int size=strlen(n3);
for(int n=0;n= 0) && (Len2 >= 0); Len1--, Len2--)
{
n3[n] = n1[Len1] - '0' + n2[Len2] - '0' + Carry;
Carry = n3[n] / 10;
n3[n] %= 10;
n++;
}
for(; Len1 >= 0; Len1--)
{
n3[n] = n1[Len1] - '0' + Carry;
Carry = n3[n] / 10;
n3[n] %= 10;
n++;
}
for(;Len2 >= 0; Len2--)
{
n3[n] = n2[Len2] - '0' + Carry;
Carry = n3[n] / 10;
n3[n] %= 10;
n++;
}
printf("两数之和为");
for(n--; n >= 0; n--)
{
printf("%d", n3[n]);
}//输出和
printf("\n");
}

是否lim A^B=(lim A)^(lim B) lim a-lim b等于什么 i think it is a problem of time ,not___of ability.A one B the one C that D a one I'm afraid it will___you a lot of time to work out the problem.A.spend B.use标题啊 we have spent a lot of time in solving the()A.question B.problem C.competition D.entertainment He did ___until it was midnightA.a problem after a problem B.problem after prolemsC.a problem after problem D.problem after problem excuse me ,sir do you have the time A.Yes,piease B.Half past twelve C.NO problem The Internet ____is useful.The problem is,you shouldn't spend much time on it.A .it B.itself 原因! I need ----- to deal with this problem.A some time B sometime C some times D sometimes lim a-lim b是否等于lima/b求解 Big schoolbags_ a large problem for student‘s for a long time .A.is B.are C.do D.does Enougu__ said on how to solve this difficult problem in such a short time.A).is B).are C).has D).has been应该是Enough It is_for her to finish the maths problem in such a short time,because she is so clever.A possible B probable理由 lt's very ______ you to work out the problem in such a short time.A.kind of B .kind for .C.clever for D.clever of i will go to hong kong for my vacation. _____A no problem B it is kind of you C oh i know D hava a good time --Jenny will probably be late for the ship,won't she?--( ).There's little time left.A.No way B.No wonder C.No problem D.No doubt Don't waste time.let's get to the/of the problem中间填啥 A type B secret C attention D heart —Why don't you continue doing your homework?——_____.A.No problem.B.I'm stuckC.Don't mention it D.Take your time