1 like 0 dislike

使用三個指標p1,p2,p3 來寫輸入兩個整數,輸出兩整數之間所有的總和的程式。例如,若使用者輸入6跟10,程序會輸出24(7+8+9)。程序必要逼使用者輸入小於100和大於0的數字,第一個數字比第二個數字小,否則輸出"Invalid value"。


輸入例子一:

6 10

輸出例子一:

24


輸入例子二:

10 6

輸出例子二:

Invalid value

 

[Exercise] Coding (C) - asked in 2017-1 程式設計(一)AD
Available when: Unlimited - Due to: Unlimited

edited by | 124 views

3 Answers

0 like 0 dislike
Hidden content!
******** ** * *

int main()
{
** ** * ** * char a,b;
* *** ****
** * * * * * * * * * ** * **** **
* ** ** **
* ** *** ** * **
** *** * * ** * * * *** *** **
* ** * * ******
*** ** *** ** return 0;
}
answered by (215 points)
edited by
0 0
prog.c:1:1: error: expected identifier or '(' before '.' token
 .
 ^
0 0
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
0 like 0 dislike
Hidden content!
#include ***** * * * *
#include ** ** ** * * **


int main(int argc, char const *argv[])
{
* ** * * * * * int * **
** **** *   int * * *
** **   * * *
*   * * * *
**** **   ** ** *
*   ** ** * **** * * * **
*** * * * ** * * *** * **** **** *** * * ** * * * **** **** * *** ** ** **** * *** )
* * * * * * *     **** **** **** ** **
******* * * else ** ** * *
* * * * ** *** ** ** * * * ** * * * * ** *** * * ***
** *********** * ** * *
**** * * ** ** *
* * * * * * ** ** ** * *** *** **
**** *** * * * ***** * * * * ***** *
* * * *** *** * * {
** *     * * * * ***   * *
* ** *** * * * ***** }
* ******** ** * ** * * *
*** ** ****** ** * * * * ** *** * );
* ** ** return 0;
}
answered by (114 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 like 0 dislike
Hidden content!
* *** * *****
int main()
{
* * **** ** * int a,b,c;
* * ** * * * int * **
** *
***** *** * * ** * * ** ** * ** * * *
* * **  
* * * *** **
*** * * ***** ** *
**** ** *
** *** ** *
****** **** * * * *** * ** * * ** * *** ** * * * *
* *** *** ** {
* * **** * * * ** * * * int i,n;
** ** *** * * * ** * * * *
** * ** * * *** ** ** n=b-a;
** *** * * *****   c=0;
* * *     ***
        * ** * *** * *
* ****** * *** ** * * {
* * * * *** * **** *** a=a+1;
* ** * * * * * ** * **** *** * * ** **
** ** ** * *** ** ** * }
* * * ** ** ** * ***** * * **
* * ** }
*** * else
* * ** ** {
***** ** ** * * * *** * *** ** * ** ** ***
* * ** ***** * }
* * *** *
* * * * * return 0;
* * * ****
****
answered by (202 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Correct output
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.158.78.58
©2016-2020

Related questions

2 like 0 dislike
5 answers
[Exercise] Essay (Open question) - asked Nov 9, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 55 views
1 like 0 dislike
10 answers
[Exercise] Essay (Open question) - asked Nov 9, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 68 views
1 like 0 dislike
0 answers
[Exercise] Multichoice - asked Nov 9, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
Available when: Unlimited - Due to: 2017-11-09 14:30
| 18 views
3 like 0 dislike
14 answers
[Exercise] Multichoice - asked Nov 30, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
Available when: 2017-11-30 14:00 - Due to: 2017-11-30 14:30
| 72 views
1 like 0 dislike
2 answers
[Exercise] Multichoice - asked Nov 9, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
Available when: 2017-11-09 09:00 - Due to: 2017-11-09 14:30
| 21 views
10,777 questions
120,945 answers
112,852 comments
3,802 users