2 like 0 dislike
8.4k views
小學一年級的數學

剛開始學習數學的時候,我們都是從個位數的加減乘除開始學習的,請寫一個程式,教你的程式學會個位數的加減乘除。

輸入說明:

程式會輸入三個字元,代表一個算式,會用下面的樣式呈現

運算元 運算子 運算元

其間會用單一個空白隔開,運算元是一個個位數的數子,運算子可能是+-*/中的任何一個。

輸出說明:

請輸出輸入算式的結果到整數位數

輸入範例:

1 +  2

輸出範例:

3
[Exercise] Coding (C) - asked in 2017-1 程式設計(一)AD by (18k points)
ID: 31085 - Available when: Unlimited - Due to: Unlimited

edited by | 8.4k views

23 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>
int main(void)
{
*** * ** * *** * * *** * **  c;
* * * * * * *** d,d1,d2;
* ** * ** *** ** * * *** ***** * %c *** *** **** ** * ***** *
* * * * * ************
    {
** * * * * ** * *** ** **** * **** * * *****
* ** * * **** * * * *** ** * * ** *** * *** ** * * ***   
    }
**** ** ** * * ** ** * if(c=='-')
*** **** *** * **
* ** * ** * ** * * ***** * ** *
* * *** * ** *** * * ******** *** ** ** ** *   
* **** * ** ** ***
* **** *** * * * * ** * if(c=='*')
* ** *** *** *** *** **
*** * * * * * ******** **** * * * * ** ***
* *** ****** * *** *** * ** * ** *** *** * * *** * *** **   
* * * ***** * **** **
*** * ** ** * ** * ** * if(c=='/')
* * * * **** ** *
* ** **** *** * * * ***** * * **** **** * *
* *** ** ** * ** * ** * * * * * *********** ***   
** ** * **** *** * *** * * *
    
*** ** * * *** * * * * 0;
*** **** * * * * ** *
answered by (215 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main(void)
{
* ** * * * * * * *  c;
**** * * * * * * ***** d,d1,d2;
* * **** **** *** *** ** * * * * * %c * * ****** *** ** * ** ***
** * ** **** *** * *** *** ****
    {
****** **** ** * * * ** * ** **** *** * *
** ** **** *** **** ** *** *** *** **** ** * ** * * ** * * **   
    }
** ** ****** *** if(c=='-')
* * * ** * ** ***
***** * * * * ** **** *** * ***** * ** ***
* * **** ** ******* *** *** ** *** ** ** ****** *** **   
**** ** ** * **
* * ** ** **** * *** *** * if(c=='*')
* ** * * ***** *
* *** * * * *** * **** * ** ** * ** * **
***** * * * *** ** ****** * *** *** ** * *** ** ** ******   
*** ** ** ** ** ***
** * *** *** * * if(c=='/')
*** ** * * ** ** * * *
** * * ** * ** * ** * ** * * ******* * ***
* * ** *** ** ***** * * **** * ******* * * * ** **   
* * ** ** ** ****
    
* * *** * *** * * 0;
* *** * * * * * * **
answered by (215 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main(void)
{
* * *** * *** * **** *  c;
** ** ** ** * ** * *** d,d1,d2;
** * **** * *** * ** ** * * * * ** * **** ** *
* ** ** * ****** * *
    {
* ** *** ** * * * **** * ** ** * * ** * ****** **
* ** * * ** * * * ** ** ** ** * * * * * ** * * *   
    }
* ** * * * **** * * * if(c=='-')
***** ** **
** * * *** ** ** * ***** *** ***** ****
* * *** * **** * * **** *** ** * ** ***** *   
* * ** * **
** * * * * * ***** *** *** if(c=='*')
** * * * ***** **
* ** * *** **** * *** * **** *** *
**** ** * * * * * **** *** **** * ** ** * ** **   
* ** ** *** ** * * *
** *** ** * ***** *** * * * ** if(c=='/')
* *** * ** ****** *
* ** *** * ***** * * * * * **** *** * * *
***** * ** * ****** **** ****** * * * ** * * ** * * *   
* * * *** * **
    
** * * * ***** ***** 0;
** *** ** * *** * ** * *
answered by (215 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include ** *** * **
int main(void)
{
**** ** ** * * ** **  c;
*********** * ** *** d,d1,d2;
** * ** **** * ****** ****** ** * * ***** * *** * * * ** *** *
* * ** ***** ** ** * * * *
* ***** * ** * ** * * ****
    *** * * **** * **
    * * ** * * ** * *** * * * * ***   
* * * ** *** **** *** *
* ** ** ** * *** ** ** if(c=='-')
***** * * * **
    * * ** * ** *** * ** * ** ***
    ***** ** * * *** * *** * *** ****   
* ** ** * * * *
* *** ********* * *** **** * if(c=='*')
* ** * ** *******
    * * * *******
    *** * * * ***** ** * ** ********* * ** * * * *
***** * *** ** * *
** * * **** * ****** ** if(c=='/')
*** ** * * * ***
    * ************* *** *** *
    *** *** * ** **** *** * * *** * *** **
** ** * * ** ***** ***
**** ** * * * ** *
* ** * * ** ***** *** * *** ** *** ***
** *** * ** * *** *** 0;
** ** ** ** * **** ** *
answered by (215 points)
0 0
prog.c: In function 'main':
prog.c:28:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
0 like 0 dislike
Hidden content!
* ** **** ** **

int ** ***
{
** ** * char * ** ***

****   ** ** *** * * *
** * * ** * ch1 = * ** ***
* * * * * * ch2 = * * * *
* * * * ch3 = *** *
* ** ***
** ** * ***** if( ch2 == 43 )
**** * * **** * * * *** *** * * ***
* * *** * * else if( ch2 == 42)
* ** * * * *** * *** ** *** *
*** **** else if( ch2 ==45)
* ***** * * * * ** ** * * *** * * * **
* **** * ** else if( ch2 == 47)
* * * * * * ***** ** * ** * *
* * * **
* ** * * *** ** * ****
***** ** ** return 0;
* *
answered by (160 points)
0 0
prog.c: In function 'main':
prog.c:21:2: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
  system("pause");
  ^~~~~~
0 like 0 dislike
Hidden content!
#include * ** *** *
int main()
{
* ** * ** ** char **** **
**** * **** ** *** * * ** **
** ** * ** * ***** ** %c * ** * **** * *** * **** *****
* * * * * * if ( ch2 == 43 )
* * * ** *** ******* *** *** ** * *
** * * * * else
*   if (ch2 == 42)
* * * * * * ** * *** * * * ** * *
****** * else if (ch2 == 47)
** * * * * * ** * *** * **** * ** ** **
**** ** * ******* ** * * *** *
* * ** *** return 0;
}
answered by (190 points)
0 0
prog.c: In function 'main':
prog.c:14:2: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
  system("pause");
  ^~~~~~
0 like 0 dislike
Hidden content!
#include * * **
int main()
{
* * ***** char *** ***
*** *** * * *** ** * * * * ** * *
* * **   ** * ** %c ** ** * * ** *** * * ** *******
** * **** * *
** *****   ***** * ***** ** * ****** ****
**   else
**   * ***
* * **** * *** * * * ** **** * ** *
** * ** else if (ch2==45)
*** ** * *** * ** **** * * **
***   else ** *
* *** * * * * ** ** * * * **
** * * ** ** ** *** ***** *****
* * * * * return 0;
}
answered by (196 points)
0 0
prog.c: In function 'main':
prog.c:16:2: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
  system("pause");
  ^~~~~~
0 like 0 dislike
Hidden content!
* * ** * ***

int main()
{
* * * ** * ** ** * * * a,b,c;
* ** *
* * * * **** ** ** * * **** * *****
* ** *** * * * ** * ** *** *
*** * ** * * *** * *** ** * ** **
* * ** *
** * * *** * switch(b)
* ** ** {
** * * ** *
* *** **
** * * ** * * *** ** * case '+':
*       ***** * * * * ** * **** * * **
** ** * * **     break;
* *   ** * ** *** * case '-':
**** * * ** ** * * * * ** * * * ******
* ** * * * * ** ** break;
*** * * ** * * ** * case '*':
* *** * *** ** ** *** * ** ** ***** ** * ***** ***
** * **** * ** *** break;
* ** ** * ** * * * case '/':
** * ** ** * ** ** * *** ** * *** **** ** * * *** * *
** * * * ** * * * ** * break;
*** ** *
** * *** * }

}
answered by (174 points)
edited by
0 0
prog.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int]
 main()
 ^~~~
0 0
prog.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int]
 main()
 ^~~~
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
* * ** *** *** ** ch1,ch2,ch3;
** * ** ** * * ** * **** * * * character: ");
** * * * *** * ** * ** * * ** %c *** ** * * ** * ******** * ** *
* ** *** * ** * ch2 == 43 )
* * * ** ** ** ** * ** * * * * *** **
* ** ** *** ** * ** *****
    if (ch2 == 42)
* ** *** ** ** ** * ** * *** * * *** *** * * * * * *
** * * * * ** ** ** if ( ch2 == 45)
* ** * **** ** ** * ** *** * * *
* *** * * ****** *** * * if ( ch2 == 47)
* * * * * **** *** * *** * ****** * *** ** **
** * * ** ** **** ** *** ** ** **** * * *
**** * ** ** * *** * ** *** 0;
}
answered by (209 points)
0 0
prog.c: In function 'main':
prog.c:16:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()
{
** * * **** * ** x,y,ans;
**** * ** *** * ** * * ch;
    
* * ** * ** * *** ***** *** %c **** * * * * * *** *
* * ***** ** * * *
** *** * *** * * ***** *
*** ****** * **** ** *
** **** ***** * ** * * * **
******* * ** * * * * *
* ** ** ****** *** * *
** * ** ****** * ** ***** * *
** * * * *** * * ***** ** *** ** **
**** *** * **** ***** * *
* **** ** * * ** * ** *
* *** * **** **** ** * * * * * *** *
    
****** * ** ** * * * ** * * *** * *** ***
}
answered by (192 points)
edited by
0 0
prog.c: In function 'main':
prog.c:34:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.159.115.10
©2016-2026

Related questions

2 like 0 dislike
29 answers
[Exercise] Coding (C) - asked Nov 9, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 31094 - Available when: Unlimited - Due to: Unlimited
| 10.2k views
2 like 0 dislike
31 answers
[Exercise] Coding (C) - asked Nov 9, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 31088 - Available when: Unlimited - Due to: Unlimited
| 11.8k views
3 like 0 dislike
9 answers
[Exercise] True/False - asked Nov 16, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 33763 - Available when: 2017-11-16 14:00 - Due to: 2017-11-16 14:30
| 1.6k views
3 like 0 dislike
9 answers
[Exercise] True/False - asked Nov 16, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 33764 - Available when: 2017-11-16 14:00 - Due to: 2017-11-16 14:30
| 1.7k views
1 like 0 dislike
0 answers
[Resource] asked Jan 4, 2018 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 40762 - Available when: Unlimited - Due to: Unlimited
| 26 views
12,783 questions
183,442 answers
172,219 comments
4,824 users