1 like 0 dislike
13.3k views

You are requested to help in writing a program to perform addition of two large number up to 50-digits. In C there is no builtin datatype for large number, but we can use characters and array to solve the problem.

Input: The input will contain two positive integers are separated by a blank, the two positive integers do not exceed 50-digits.

Output: Sum.

寫一個程式輸入兩個大數(最大50個位數),計算其總合。C語言不提供大數資料型態,但我們可以用字元和陣列來解決這個問題。

Example input:

999999999999999999999999999999 999999999999999999999999999999

Example output:

1999999999999999999999999999998

 

[Exam] asked in Final Exam
ID: 42300 - Available when: 2018-01-17 14:00 - Due to: Unlimited

retagged by | 13.3k views

32 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,k,n,t=0,c[53]={};
* * ** * ** * *** **** a[51],b[51];
* * * * * ** ** * * * ******** %s",a,b);
* **** * * * ** ** * * * *
* ** * * *** ***** *** *
** ** * *** * * **** * * ** * **
* ** * * ** ** * ** ** *** * *** * * ** * ** **
    }
** ** * * * ** * ** * ** * *** *
* * * **** * * ** ** ***** ****** ** ** * * ****
    }
* ******* ** * ** * * * ** * *** *
*** ** * *** ** ** *** ** *** * ** **** * **** ***
** ** * * ** ** ** ****** **** * **** ** ** *** * * *** * * * ***
* * ************* * ** *** * ** *** * *** * **** *** * ** ** ** *** **
* ** * * **** ** *** * * * * ** *
    }
*** **** * * *** * ** ***** **
* * * ** * ** * * * * ** * * * * **** || t!=0){
* ** **** * ** ** ** ** ** *** * ** ** *** * * ** * *** ** ** *** ***** * ** *
* ***** * * * * *** ** ** * ** * ** ** **** **** * *
*** * * * * *** * * ***** * * * **** *
    }
**** *** *** ****** *** ** * *** 0;
}
answered by (54 points)
0 0
prog.c: In function 'main':
prog.c:7:7: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     k=strlen(a)-1;
       ^~~~~~
prog.c:7:7: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:7:7: note: include '<string.h>' or provide a declaration of 'strlen'
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
prog.c: In function 'main':
prog.c:19:22: warning: division by zero [-Wdiv-by-zero]
             c[i]=c[i]%0;
                      ^
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include *** ** ** ***
** * * ****

int main()
{
**** * * * * * ******* * *** * *
* *** * * * ** * * * **** 0;
}
answered by (-108 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.100.103
©2016-2025

Related questions

1 like 0 dislike
37 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42302 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 12.6k views
2 like 0 dislike
31 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42301 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 11.5k views
1 like 0 dislike
37 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42299 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 12.9k views
2 like 0 dislike
30 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42298 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 10.2k views
0 like 0 dislike
8 answers
[Exam] asked Jan 19, 2018 in Final Exam
ID: 43461 - Available when: 2018-01-20 09:00 - Due to: Unlimited
| 2.7k views
12,783 questions
183,442 answers
172,219 comments
4,824 users