0 like 0 dislike
8.2k views
Show more...
[Exercise] Coding (C) - asked in Chapter 12: Pointers and Arrays
ID: 38251 - Available when: Unlimited - Due to: Unlimited

edited by | 8.2k views

58 Answers

0 like 0 dislike
Hidden content!
#include ** ******

void * **** ** a[], int n, int *largest, int **

int **
{
***** * * * int n, largest, * * *
** * ** * ** * * *** ** * **** *** * //Numbers will be entered
* ** * * *** int a[n],i;
* ** *** *** * *** **** n integers separated by spaces
* ** ***** for (i = 0; i < n; i++)
* * *       ** *** *** ** * * * ***

*** * *   ** *** * * n, * * ** * * * * ****

* **** * if (n == 0)
* * * * * *** * ** *** {
* ** * * *** ** ** * ** **** ******* * * ** *** ** ** *** * ** ** numbers were *** * ** ** **
** * * * * ***** *** * }
* * ** * * else if (n == 1)
*** * * *     {
* * * * *** **** * * ****** *** **** ***** *** * * *** ** ** ** ** one number was entered. Largest: * *** * a[0]);
** *** * * *** * *** * * ** }
* * *** * else
***** * * *** ** * {
****       ** * * ** ** ** * * * * %d, Second Largest: * ** **** ** ******* ** * * *** * ***
* *       }

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

void ** *** *** a[], int n, int *largest, int ** ** *
{
*** ** * * int i;
* * * *** *** * * **
* * ** ** * * ** ****** * *
** * ** * * ** * ** ** * * ** ** * ** * * ** *
** * ********* ** *** * ** ** * * **** * * * *** ** *** ** **** * ***** * ** * **
** ** * ** * * * * * * ** *** ** * * ** **** *** * ** * * **
* * *** ** * * **** * * * ** * ** * ****** *** * *** * ***** = *largest;
* **** * * *** ** * * * * * ******** * **** ** *** * ** *** ******* = a[i];
**** ** *** * * ** * * **** ******* * * * * * **
* * ** ** ** * *** **** ** ** * ** ***** ** * * * * *** ** ** ** *** ** * *** ** *** *** ** ***
**** * * * * *** * * ** ***** *** * ** *** *** * * ** * * **** *** *** ** * = a[i];
** * ** * ** * *** ** * **** ** * * *
}
answered by (-32 points)
edited by
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Correct output
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 ** * ** ** **

void * * * ** a[], int n, int *largest, int ** *

int main(void)
{
    int i, n, largest, * * * * **
    * * * * ***** * * * * * //Numbers will be entered
    int a[n];
**** *   if (n == 0){
* * * ** ** *** ** * * **** * **** ***** ** numbers were * ** ** * *
    }
** ****** * * ** * * n integers separated by spaces
** ** **** * * ** ** **
* ** * **** * *** * * *** * * * ** * ** * *** (i = 0; i < n; i++){
*** **** * * **** * ** **** ******* *** * * * ** * *** ** ** ** * * *** **
* * * * * ** * * ** * * ** **** * ** ******
** ** * ** * * ** ** * * * **** * ** * ** ** * n, ** * * * * ** *


* * * *** * ** *** **** * * * * * * **** ***** Your code here
** ****** ** ** ********* **** ******* ** ** * * * *** *** ** ** No numbers were entered.
* ** * ****** * * * * ** * * * *** ** * * ** * (n == 1){
* * * * * **** * * * * ** ** * ** * * **** ** *** ** ** ** * one number was entered. Largest: * * ** *** * * *
** *** * * * ** ***** ** ** * ** ** *** *
* * ***** * ** * ********* ** ***** * **** * * * *** ** *** ****** Your code here
***** * * ********** ** ** * *** * ** * * * ** *** * * ** ** * * *** * Only one number was entered. Largest:
** * ** *** * *** *** * ** * * ** * * * ** * * *
* * ** ****** *** ** * * * **** ***** *** * * ** * * *** * * ***** * * * %d, Second Largest: ** * **** ** * **
**** * ** * * * * * ** ** * ******* *
        // Your code here
        //Print Largest: , Second Largest:
** * *** ********* ****
* * * *   return 0;
}

void * * * *** a[], int n, int *largest, int * *
{
* ** *** * *** * *** **** i;
* * *** ** * ** *** * ** **
**** * *** * * * * ** * *** * *
****** * * * * * ** * *** * *
************* * * ********* ** * * ** * * * * * *
**** * * * *** * * * *** *** *** * **** * ** **** ** * ** * * *
**** ** * * * ** * * ** * ** * * * **** ** * * * ** ** * * ***
* ** ** ** * *** ** * *** * * *** ****** * *
** *** *** * * * * * * *** * *** * * *** * * ** ** * ** *
* * * ** * * * ** **** * * *** ** * * ** * * ***** **** * ** ** **** ** * **** ** **
** * * *** * *** * * ***** ** * * * * ** *
**** * *** * * ***** **
** **   // Your code here (Using pointer to finish)
}
answered by (54 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
* *** * * ****

void * ** ** * * a[], int n, int *** * int * **** * *

int * **
{
* *** ***** int i, n, largest, * * *
**** ** ** **** * ***** * * * * * * will be entered
* ** * * int a[n];
** * * ** if (n == 0){
* **** *** * **** ****** * * * * ******* ** numbers were * *** **
** ** * }
** ** ** *** ** * n integers * * ** by spaces
* ** * * for (i = 0; i < n; i++){
**** * * * * * * ** ** * * *** ** ***** ** * **
* *** * * * *
** ** * * *** ** n, ** ** ** ** * ** * ** *

** * * *
** * ** *** * **** ** ** // Your code here
* * **** * * * * * //Print No numbers were entered.
*** * * ** * if (n == 1){
* **** * * * ** *** * ** * ** ** **** ** *** * * ** * one number was entered. Largest: * * * * ***
* *** *** }
* ** * * *** ** *** // Your code here
** * * ** ** * * * ** **** //Print Only one number was entered. Largest:
* *** * * * * else{
*** ** *** * * ** ** * **** * ** ** ** * %d, Second Largest: * **** * * **
**** ** ***** }
* * * * * * * * * * * * // Your code here
**** * * ****** //Print Largest: , Second Largest:

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

void * * * * a[], int n, int * * int ** *
{
***** **** * * ** * i;
*** * * * * * * * * * **** *
*** *** * * ****** ***** * * **
** ** ***** ** * * * ** * * ** *** ** * *
* ** **** * * ** * ** ** **** **** * * ** * ***
* * * * * *** * * ** ** * **** * * * ** ** * ** * ** * *** * * * * **
* * * * * ** ** * *** * * **** * ** ** * * * *** * ** * * * * *******
*** * ** * ** **** * ** *** * * * ** *
* * * ***** *** **** *** * * ***** *** * *** *** ****
*** ** * * *** *** ** * *** * * ** * *** **** * * ** ** * **** ***** * * *** * * * * **
** ** * ** * *** * * * * ** *
** ** * *** **** * **
** ** * *** // Your code here (Using pointer to finish)
}
answered by (54 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include ****** * ****
* * * * * ** * ** *
void * * ** a[], int n, int *** * int **** **

int *
{
** int n, largest, ** * *****
* *** * * * ** * * * ** * * ** * will be entered
*** ** * *** char c;
* * * * c = * **
* ** * * *
** * ***** * * ** * ** * * ** * * ***** * * * * *** **** numbers were ****** ***
** ** * * **** ***** *** *** ** ** ** * * * ** * 0;
* *** * * * * }
** * * ** ** int a[n];
* * *** * * * * ** * ** n integers ***** * by spaces
* ** ** **** * ** * * * * i = 0;
***** * for (; i < n; i++)
* **** ** ** ** * * * * * ** ** * *

******** * *** * * * ** ** n, * * * * * ** * *

*** ** * * if (n == 0)
**** **** * * * * // Your code here
******* * * * *** *** * * **** ** numbers were ** *** * **
** * ** * * *** * //Print No numbers were entered.
* ** ** * else if (n == 1)
* * * * * * **** * ** * * // Your code here
**** ** ** * * ** ** ** * * * ** ** * * **** one number was ** ** ** * ** * * *
** **** *** * * * ** //Print Only one number was * **
* * * else
***** ** *** ** * **** * // Your code here
** * * * *** ** *** * * * ****** *** * * ** ** * * %d, Second Largest: ** ** largest, ** ***
* ** * *** * ** * //Print Largest: , Second Largest:

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

void * ** ** a[], int n, int * * int ** *** *
{
** **** * * ** * * * * * *

*** * * **** * * * *** * * i=1;
* ** *** * * ** *** *** * ** ** ****
* * * ** * * * * * **** ** **** * * * ****** * ***** *** * ****
* * ******** ** ***** * * *** * ** * ** * *** *** * * ** * ******** *
* * *** * * * * *** * ** ***** ** ** ** * * * * *** ***
** ** ** * * *** * * * ** ***** ** **
** * * * ***** *** ** * * ** ******* * * * * *** * *
* ** ** * ****** ** *** ***** ****** ***** **** * ** * * ********* * *
* ** ** ****

****** ***** // Your code here (Using pointer to finish)
}
answered by (-116 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include * * **** ** **

void * **** * a[], int n, int *largest, int ****

int main(void)
{
* * ** int n, largest, * * * ** *
*   ** * * * * ** * * //Numbers will be entered
* ****   int a[n];
***** * * ** * n integers separated by spaces
**** **   for (i = 0; i < n; i++)
* **** * * ** ** *   ** * * ** * * ********** **

* **   ** *** * n, * * ** * * ** *

* *   if (n == 0)
* * * *   * *   {
** *       *** * * ******* *** ** * * ** * numbers were * *** * **
*** * ** ***** * ** }
**** ** * else if (n == 1)
* * * ** **** ** * * * *** {
* *** * * * * ** * * * * ** ** ******* * * * * one number was entered. Largest: * * * * **
* * * * * * }
**** * * * ** else
* * * * ** ** * **** ** * %d, Second Largest: *** * * ** * *

* * * return 0;
}

void *** ** ** a[], int n, int *largest, int **
{
** *   int i,b;
* * ** *** * *largest = a[0];
* *** ****** * * ** = a[1];
**** * * * ** * ***** * *
** * * * *** * * * *
* * ** ** * * * * ** * * * * *** * * * * *** * ****
*** ** ** ** * ** * * * ** ****
* ** ** ** * ** ** * **** *** *** * ** ** ****** ** * * * ** ** ** * = a[i];
* * * * *** ** * * * * *** *

** * ****** * ***** **** *
****** * **** **** *** *** *** ***
**** * ***** * ** ** *
* * * * ********* ** ** ***** * **** **** **** * ** *
*** * ** * * * ** * ******* *** * ** *
* * **** * ** ** * ** ** * * ** * *** ** ** *** ** ** **** * ********* ** *
** ** * *** ** ** ** ** * ** ***** *** *** ***** **** **
* * * *** * * *** * * * * *** * * * * ****** *** * * **** * ***** ** **** * * * * ** * ** = a[b];
* * * * * ******* * * * **** ** ** * ** * ****** ***** ** * * **
* **** * * ** * **** ***** ****** **** **** ***
*** ****** ******

* ** * ** *** *** *** * * ** * ***
}
answered by (-323 points)
0 0
prog.c: In function 'find_two_largest':
prog.c:54:20: warning: 'return' with a value, in function returning void
     return *largest,*second_largest;
                    ^
prog.c:30:6: note: declared here
 void find_two_largest(int a[], int n, int *largest, int *second_largest)
      ^~~~~~~~~~~~~~~~
0 0
prog.c: In function 'find_two_largest':
prog.c:54:20: warning: 'return' with a value, in function returning void
     return *largest,*second_largest;
                    ^
prog.c:30:6: note: declared here
 void find_two_largest(int a[], int n, int *largest, int *second_largest)
      ^~~~~~~~~~~~~~~~
0 like 0 dislike
Hidden content!
#include * * * ***** *

void * *** ** * a[], int n, int ** int *** ** **

int ** * *
{
* * ** int i, n, largest, * * ** **
* * **** * * **** * * ** ***** ** * *** will be entered
* * **** int a[n];
* **** *** ** * ***** n integers * by spaces
* * * ** for (i = 0; i < n; i++){
*** **** * * * ** * * * * * * ** * ** ** * *
*** ** * ** * * ** *****
*** * ** *** * ** *** ** n, * ***** * * * * ** * ****

* ** * ** * * if (n == 0){
*** **** * * * * ** ** ******** ** *** ***** *** * * numbers were * ** **
******** ** }
* * ** * * *** ** *** ** * // Your code here
* * * * *** ** * //Print No numbers were entered.
* * **** * else if (n == 1){
* * * ** * ** * * ***** * ****** *** ** * ** * * * one number was entered. Largest: *** * * * * * *
* ****** }
** ** ** * * * * * // Your code here
* * ** * *** ** //Print Only one number was entered. * *
*** ** ** ** * else{
* * * ** ** *** * *** ******* *** * * * * * * * * %d, Second Largest: * *** * ***** * ****
* * ** }
* ***** ** * * * ** ** ** * // Your code here
* * * *** ** * * * * //Print Largest: , Second Largest:

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

void ** ** **** *** a[], int n, int *** ** int * **
{
* * *** ** **** ** **** i;
* * * * ** ***** **** **
** * ** ** * ******** ** **
*** * * * * **** * * * * *** *
*** * * ** * ** * * * ** ** * * * ** ** ** ** ** *
* ** **** * ** ** ** ** ** *** * *** ** * ** **** ***** ** **** ** * *
*** * ** *** **** *** **** *** * * * ** * * *** * ****** * *** *** * **
** ** *** * *** * ** * ** * * *
**** ** ** * **** * * * * * * * * * *** ** ** * * **** *
* * ***** * * ** *** * **** ** * * **** * **** ***** * * ** * * * **** **
*** * * ** ** ** * * * *** ** ** ***** *
**** * ** **** **** * *
* * * // Your code here (Using pointer to finish)
}
answered by (54 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include ** * * ***
* * *** ** * ** **** ***
void *** *** a[], int n, int int ** *******

int * *
{
* * * ** * int n, largest, * ***
* * ** * * ** * * * ** * ** will be entered
** ** ** * * int a[n];
** * ** ** *** ** * ** n integers ** * by spaces
* * * * *** * ** **** i = 0;
* ** ** * * for (; i < n; i++)
** * * * ** * * ** * ** *** ******

*** * ** **** * * * * ** n, ***** ** ** * * ***

* * * ** if (n == 0)
** **** **** ***** // Your code here
** * ** ** * ** * * * * ****** numbers were ** * *
*** * **** * * * **** //Print No numbers were entered.
* * * **** else if (n == 1)
** ** ** * ****** ** ** // Your code here
* ****** * *** ***** ** * * * * ** **** * * *** ** one number was ** * ** * ******** * * *
** * * *** * * ** * //Print Only one number was *** * *
* ** * * else
** *** * * * * * // Your code here
* * **** ** *** ** * ** * * ***** ** * * **** * * **** * %d, Second Largest: * * ** ** ***
** * ** * ** * * ** //Print ****** , Second *

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

void *** * * * a[], int n, int * int ** *
{
*** ** ** * * * * **** * ** * *** ** **
** * *** ** * * ** i=1;
******* *** * *** * * * *** **** **
** * ***** *** * * *** * * * * *** * * * ** **
* ** ** * ** ** * * ** * *** * * * **** ** ** * ** * * * * * * *
* * ********** * * *** * ** **** *** *** ** * * * ** * * * * *** * * * * **
** * * *** * *** ** **** * * * ** * *
***** ** * * ** ***** * **** * ** *** ** * * * ***** ** ** *** *
* * **** ** * ** ** * * * * ** ** **** ** * *** * * *** * * * * *** * * **** ***
* ** ** * ** * **

** **** * * * // Your code here (Using pointer to finish)
}
answered by (-116 points)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
** *** ** * ****
* ** * *** * *
void * ** * * a[], int n, int *** int ** * ** ***

int * **
{
* ** * * int n, *** * ** *
* *** * * * *** ** ** * * ** ** ** * will be entered
****** *** * int a[n];
* * ** ** *** ****** ** n * ** * by spaces
*** * * *** for (int i = 0; i ** n; i++)
* * ** * ** ** * *** *** * * *** * * * ***

** * * * * * *** * n, ** **** * ** ** * ***

*** * *** if (n == 0)
** * * * * **** ** * * // Your code here
**** ** *** * * ****** * * * were * * * *
* ** * ** * * * *** * * No **** were * *
** * * *** else if (n == 1)
* * * ***** * * * // Your code here
* * *** * * **** * ** *** **** * ***** one number was * *** *** ** *
*** * ** *** ** ** Only one number was * ****
* * * * * * ** else
* ** ** * ** ** * * * * // Your code here
*** ** * * ******* * ****** * * * ** * * ** * ** ** * * %d, Second ** ** ***** * ** * **** * *
*** * ** * ** ** * *** ** , Second *

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

void **** * a[], int n, int *** int * ** *
{
* * * ** * * * * * * * * * ****** * ***
** **** * * ** * ****** *** * i=1;
* **** ********** * * ** * ** *
**** **** ** **** ******* ** * *** * *** ***** **** *** *** *** ** *
* * * * * *** * ***** * * ** * * *** **** * * ** * *** ***
** * ***** * * *

* * **** ** ** // Your code here (Using *** ** to ** **
}
answered by (-116 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.7.143
©2016-2025

Related questions

0 like 0 dislike
30 answers
[Exercise] Coding (C) - asked Dec 21, 2017 in Chapter 11: Pointers
ID: 38255 - Available when: Unlimited - Due to: Unlimited
| 4.9k views
0 like 0 dislike
58 answers
[Exercise] Coding (C) - asked Dec 21, 2017 in Chapter 12: Pointers and Arrays
ID: 38252 - Available when: Unlimited - Due to: Unlimited
| 7.3k views
12,783 questions
183,442 answers
172,219 comments
4,824 users