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

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

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

輸入範例:

999999999999999999999999999999 999999999999999999999999999999

輸出範例:

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

reshown by | 947 views

16 Answers

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

#include <stdlib.h>



int main()

{

    char a[50]={0};

    char b[50]={0};

    char c[50]={0};

    int n,t=0;
* * * * * * ** * ** * *
** ***** * *** * * * *** *

    {
* ** * *** *** ***** ** *** * * * *** * **
* ***** * * * * ** * * * * * *** ** * ** *
** ** * * ** * * * ***** ** * ** *** * *** * ** * ** * * * ** * * * * ** * **
*** * ****** * ** ** * ** ** *** * *** ** * ** * ** ** **** ** ***** *** * *** ** ** * * ** ** = a[n] + b[n];
* **** ** * * * * * *** ** * ** ** ** ** ** *********** * * * ** * if(a[n]+b[n]>='10')
** * ***** * * * **** *** * * * *** **** *** * * ** ****
**** ** ********* * * ** **** * *** * ** ** ** * * * **** * *** ** * **** * *** * *** * = a[n] + b[n] - '10';
***** ** *** *** * * ** * * *** ****** **** *** ** *** *** * ** * * * ** ** * ** * * *
* ** * * *** *** ** *** * **** * * ** **** ** * * ** * ** ** ********
* * ****** * **** ** ** * * *** ** * * *
* * * ** * ** * ** * **** **** * *** ** if(t == 1)
*** * ** *** ** ** * *** ** ** ** *** **
* ** * * *** * ** ** * ** ** * * ** ** *** * *** **** * ** *** ** *** * *** ** *** *
**** * ** ** ** * ** *** ** ** * ** * **** *** * * * ***** *** * *** *** * = a[n] + b[n] + '1';
* * ** ** *** * ** ** ** * * * * * *** * *** * * *** *** if(a[n]+b[n]>='9')
** * ** ** *** **** *** **** * * *** * ** * *** **** * * * * * ***
* * ** * ** * ** ** ** ** *** *** **** * *** * ** ***** * *** *** * ** * * ** * = a[n] + b[n] - '9';
***** * * * ***** ** ** * * ** **** ** * * ***** * ** * * * * * *** * ** ** ** ** ****
* * ******** ** * * **** * ****** * ***** * * * * * *** *** *
* ******* * * * ** *** * * ** * **** **

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

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

    }

    return 0;

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

int main ()

{

int ****


** * ***** * * ** ** *
** * ** * ****


* 0;

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

#include * ****** * *

#include <ctype.h>

#include <math.h>

#include <stdlib.h>



int main(){
*** *** * ** * * * * ** * a[100],b[100];
* * * ** * ** ** * sum[200];
********* *** *** * ***** ** *** la,lb,lm,i,j,k;
*** ** ** *** *** ****** * * %s",a,b);
* *** *** *** **** *** = strlen(a);
* *** ** ** *** * ** = strlen(b);
** ** * *** ** **** ***** **** *** ** *** **
*** *** * ** ** * * * ** *** ** ** * ** *** * * = a[i];
** *** * * * **** * * ** * ***** * *** **** *** * * * ** **
** **** *** * * * *
******* * * ** ****** * ******** ***** ** **
***** * ** ***** ** * * * * *** * ** * **** += b[i]-48;
***** ** *** **** *** *** ** * * * * * ** * ********* * * **
* **** ** ** * ** ***
*** ****** * *** ** ** * * = strlen(sum);
** * ** * ** * * ** ** * * ***
** *** * *** * ******* *** * * * * * **** * * * **** * ** *
** ** *********** * * * * * *
* ** ** **** * *** *** *** 0;

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





int main ()

{
a , b ;
* * * ** * *** , **** *
***** ** * ** , ** *** *
*** *** ** *** ** * ** ,a+b);
*** *** *** * ***** ** * 0 ;



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

#include <stdlib.h>



int main()

{

    char a[50]={0};

    char b[50]={0};

    char c[50]={0};

    int n,t=0;
* * * * * * *** *** * * **** ***
** * * * *** ** * ** ** *** *

    {
** * * * * * * ** ** ** ** **** * * * * **** *****
** *** *** ** *** *** * ** * * ** ** ** *
** * * * ** ** ** * * * * ** * *** ***** *** ***** ** * ****** * **** ***
* ** ** **** ** *** ** * **** ** * * ** *** * ** ********* * *** * *** ** ** **** ***** = a[n] + b[n];
** *** ** *** * * ** **** * ** * * ** * ** * * * ** ** * *** ** * * ***** if(a[n]+b[n]>=10)
* * **** * *** **** * * * * * *** * * * * *** ******* *
* ** ** ** * **** ** * ** * ** * ** ** ** ****** * ***** * ** ** * * **** *** ** ** * = a[n] + b[n] - 10;
* * *** * *** * *** ***** ***** ** **** * ** * * ** ** * ** *** * * ** ***** **** **
*** * ** ** * * *** *** ** ***** **** * ** * * * **** ** * ** *
* * ** *** * * **** * *** * * * *** ***
***** * *** * * **** ****** * * ** if(t == 1)
*** ** * * * ** **** **** * * * *** * *
* ** *** * * *** ** *** ******* * ** * * * * *** * * **** ***** *** * * * *
* ***** ** ** ** ****** ** * * * * ****** ** * ** *** * * * * ** * = a[n] + b[n] + 1;
* ** *** *** ***** ** * ** **** *** ** ** * ** * ***** ***** ** * * *** if(a[n]+b[n]>=9)
* **** * * ******* **** **** * * * * * * * **** ***** ** ** *
**** ** **** ******* *** * * * ** *** * *** * ***** ** * ** ** * ** * *** ** * *** * * * * * = a[n] + b[n] - 9;
* * * * * * ******* ** * ** ** * * * * ** ****** * ** ******* * ** * * ** ** * * * *
** ** ** ** ** * * *** ****** * ** *** ** * **** ***** *** *** *
* ** ******* ** * * *** *** ** * ***

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

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

    }

    return 0;

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

# include <ctype.h>

int main()

{
** *** * *** * ** * * * data[2];
* **** * * ** * ** sum;
* * * * ** * * ** i;
** * * * * *** * ** ***** ** ** ***
** ** *** * *
* ** * * * * * * * * * ** * * * ********** * ** * * *** * * * ** *
**** *** *** * * * * * *
* ** *** *** **** ***** ***** *
* * * * * ***** ** ******* * * ** ** *
* * * * * *** **

}
answered by (-124 points)
0 like 0 dislike
Hidden content!
#include *** ** *
* * * **** *****
* * ** *** * *
** * * ** *****







int ***

{


** ** ** ** int ** ** ** **
** * *

* * ******** scanf * ******* * * ***
* * **

** **** * while (a[i]!= ' ')

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

*** * i++;
* * ** * **

** * * **** scanf * * * **** **** * * * * **

*** * *

}


* * **** * * * scanf * *** *** * * * * **


**** * * *** while *** ** * **** **** * ***
** ** ** *

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

* * ** * ** * * ** * j++;
** * * * *** * ** * *

*** * ** **** * * ** scanf *** ****** * ***** * ** ** * **** *

*** * * ** ** * * ** * ***** * *

* * * ** }
* * * **

}
* * *

* *** * for (i = 0,j = 0;;i++)
*** **

****** * * * return 0;

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

#include * * ** * * *

int main()

{
* * * ******** a,b,c;
* * * * ** **** ** * * ** ** ** *
* ***** * *** * * **** * = a + b;
** *** * * * ****** * * ****** ** ** ** *
****** * * ** * ** * *
** * ** ***** ****
** * **** * *** * * *** ** * **
* * ** * ****** * ** * 0;

}
answered by (-42 points)
0 like 0 dislike
Hidden content!
#include * * * ****

int * * ** y=999999999;

int main()

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

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

int main(){
* *** ** ** * * * ******* a,b,c=0;
* ** * * *** ** * *** * ***** ** *** *
* * * * **** **** * * * ***** **
* **** * * * * * ** **
* ** ** *** **** *** * *** ******* * * ** *
**** * ** **** ***** * 0;





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

Related questions

0 like 0 dislike
86 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 18071 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 3.4k views
0 like 0 dislike
49 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 18070 - Available when: Unlimited - Due to: Unlimited
| 2.1k views
0 like 0 dislike
62 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 18067 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 2.7k views
0 like 0 dislike
21 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 18066 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 1.1k views
0 like 0 dislike
0 answers
[Resource] asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 18085 - Available when: Unlimited - Due to: Unlimited
| 10 views
12,783 questions
183,443 answers
172,219 comments
4,824 users