1 like 0 dislike
2.6k views

使用三個指標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
ID: 29808 - Available when: Unlimited - Due to: Unlimited

edited by | 2.6k 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
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.243.108
©2016-2026

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)
ID: 31079 - Available when: Unlimited - Due to: Unlimited
| 1.6k views
1 like 0 dislike
10 answers
[Exercise] Essay (Open question) - asked Nov 9, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 31078 - Available when: Unlimited - Due to: Unlimited
| 2.2k views
1 like 0 dislike
0 answers
[Exercise] Multichoice - asked Nov 9, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 31077 - Available when: Unlimited - Due to: 2017-11-09 14:30
| 738 views
3 like 0 dislike
14 answers
[Exercise] Multichoice - asked Nov 30, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 34984 - Available when: 2017-11-30 14:00 - Due to: 2017-11-30 14:30
| 2.9k views
1 like 0 dislike
2 answers
[Exercise] Multichoice - asked Nov 9, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 31076 - Available when: 2017-11-09 09:00 - Due to: 2017-11-09 14:30
| 947 views
12,783 questions
183,442 answers
172,219 comments
4,824 users