0 like 0 dislike
271 views
整數的運算會因為整數所佔的記憶體大小而有限制,無法計算太大以及太小的數字,但是如果利用字元以及陣列的結合,就可以大大的提升整數運算的範圍,請設計一個程式,讓使用者輸入兩個很大的整數,程式會把兩個整數相加後輸出。

輸入說明:輸入會包含兩個正整數,兩個正整數之間會用一個空白隔開,兩個正整數相加的結果不會超過五十位數。'

輸出說明:請將兩數相加的結果輸出。

輸入範例:

999999999999999999999999999999 999999999999999999999999999999

輸出範例:

1999999999999999999999999999998
[Exercise] Coding (C) - asked in 2016-1 程式設計(一)AD by (18k points)
ID: 18074 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00

reshown by | 271 views

5 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>
* * ** * * * ** *
* * * ** **** * *



int main()



{
* * * ** ****** * * *** * * int x,y;
* ***** * * * **** * ****
* * ** ** **** ***** * *** *** * **
** * ** * * * *** * * ** *
* * ** ** * * ** ** * * *** ** * ***  


* *** * * ** ** ** * *** * * ** *
** * * * ******* * **
* ****** ** * *** *** * 0;  

}
answered by (122 points)
0 like 0 dislike
Hidden content!
* * *** ** * * ***
** *** * *** *** *

int **

int * ***

int n=0;
* *** *** *** * *** ******** **

n=a+b;

int x=0;

if ( *** (n)){
* * *** ** * * *** ** *** * ** * * ** * ******* * ** *****
**


** * * * *** * *
* ** 0;



}
answered by (-304 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
********** * ** ***** * c ;
* * **** ** * **** * i , j , k , m ,a1[50] , a2[50] ;

    
*** ***** ** ** ** * * ; c!=32 ; i++)

    {
** ** ***** * ** ** ** * *** * ** * * ** * * * **** ****** *** * * *
******** * ** ** ******** ** ** * ***** && c<58)
*** * * ** **** ****** * * ** * * * * ** ** * * * **** * = c % 48 ;

    }
** ******* * * ** **** * * * ; c!=10 ; j++)

    {
* **** * ** *** *** ** * * * * ** ** ** * * ** ** ** * * ** ** *
* * * ** * * ** ** * ** ** ** * *** && c<58)
* * * * * ** * *** *** * ** * * * ** ** * * ** * * *** *** = c % 48 ;

    }
* ** *** ** * ** ** *
*** *** ** * * ** *** *
* * ** * * *** *** *** * **

    {
*** * * *** ** * ** ** * * ** * * * ** * ***** ***
** * * * * ** * ** **** * *** * ** ** ** **** * **
** * ** * * *** * * * *** **** * ** **** **** *** * * *
** **** *** ** ** * ** * *
**** ****** ** * * **

    {
* * * * * ** * * ** * * ******* ** * * ** ***
*** *** * ** **** ** *** * * ** **** * * **** * * *** * * ** * * **
***** * ** ** *** **** * * **** **** ** * ** **

    }
*** ** ** *** * *** * a3[i+1] ;
* * * * **** * ** **** * ** *** *
* * * * *** * **** * * **** * **

    
* * **** *** * * ** **** ; k<=(i+1) ; k++)
* * * **** * ** *** ****
* * * ***** *** ***** * *** ** * ** ***** *** * = (a1[k]+a2[k])%10;
** * ** * ***** **** * * * * * * ** ***** **
* * * * ** ** * **** ***** ***** * *** * **
*** ***** * *** ***** * ** * *** * ****** ** * *** *** * ** ** * * * * ** *** * ** * * * * ** * * *
* * ***** ** **** * *** * *** *** ** * ** * * ** * ***** **** * ** * ** ** *** **
* * * * **** * ****** * ** * * ****
** * * ** * ** ***** *

    
* * ** * ** ** ** * ** *********
***** * ** * * * * ** * * ** * ** * *** * *** * ** *** * *
* * **** * ** *** **** *** ** * * ** *
*** ******** ** * * * ***** * ** * * *** *
* * * * ** ** * * * 0;

}
answered by (-162 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>
* * * ** * * *

#include<ctype.h>



int main()



{
* ** * *** *** i,j;
** * ** * * * * *
*** * ** * ** * **** ** * ** * ** ******** * * ** **** ** ** ***
*** **** ** **
** * * ** * *** ** * * * * * * * ***


* * *** * *** * * *** ** * *
** **** * * * * ** *** **
** * *** *** ** * ** **** * * 0;  

}
answered by (122 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>

#include <string.h>



int main(int argc, char *argv[]){
* * ** * * * * ** **** *** * * *** *** ** ***** ***
*** ***** ** * *** * * ** i,j,len,na,nb,carry;
** * * ** ****** *
* ***** * * **** ** **** * * **** %s",a,b);
* *** * ** ***** * * ** ** * = strlen(a);
* * * *** *** * * ** * = strlen(b);
** ** *** *** *** ** * * * *
* * * ** * * * *** * ** * >= 0; i++,na--)
* *** ** * * ** ** * * * ** * ** * = a[na]-'0';
* ** *** ****** ***
** ***** * * ** * ** ** ** * * >= 0; i++,nb--){
** ******** * * * ******** ***** **** * * **
******* *** * **** *** ** ** *** **** ** = c[i] + b[nb]-'0';
** ** **** ** * *** * ** * *** * * ** *** * *** %d\n",j);
* *** ** ** ****** ** **** **** ** ** * >= 10){
** * * ** ** ** * ** * ** * * * * **** * ***** ** * *** = j/10;
** * * * ** ** ** * **** * ***** ******* = j-10;
**** ** * * * *** ** *** * *
** *** *** ***** **** *** ******* **** = j;
* * **** * *** * ** * ** *** ** ***** ** * * ** += carry;
** * * * *** *** * ** * * ** * * * *** * ** %d %d\n",i,carry);
* * ** ** * ** * *
* ** * * ** **** * * * * * ** * %d\n",carry);
** * ***** *** ** * * *
* * * ***** * * * ** * * ** ** == 0)
* * * *** * ** * * ** ********* **** ****** >= 0; i--)
* * * * ** ******* ** * * * * * * ** * * * * ***** **** ** * **
*** * ** * * * ****
** ** * *** * *** **** * * * >= 0; i--)
* **** *** * ** * * * ** * ** * * * * ** * * ** **** * ** ** ** *

  
** **** ** ** * *  
* ** *** ** *** 0;

}
answered by (-216 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.100.201
©2016-2024

Related questions

0 like 0 dislike
96 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18072 - Available when: Unlimited - Due to: Unlimited
| 1.7k views
0 like 0 dislike
13 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18069 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 378 views
0 like 0 dislike
67 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18068 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 1.2k views
0 like 0 dislike
11 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18065 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 326 views
0 like 0 dislike
0 answers
[Resource] asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18084 - Available when: Unlimited - Due to: Unlimited
| 7 views
12,783 questions
183,443 answers
172,219 comments
4,824 users