0 like 0 dislike
16.7k views

We will use this function to proceed and store the result 

void find_two_largest(int a[], int n, int *largest, int *second_largest);

* When passed an array a of length n, the function will search a for its largest and second-largest elements, storing them in the variables pointed to by largest and second_largest respectively.

寫 find_two_largest() 函數。陣列做為函數參數 找出最大值跟第二大值。

Finish the code below to match the input and output. Pointer is required. 請使用指標。

#include <stdio.h>

void find_two_largest(int a[], int n, int *largest, int *second_largest);

int main(void)
{
	int n, largest, second_largest;
	scanf("%d", &n); //Numbers will be entered
	int a[n];
    //Enter n integers separated by spaces
	for (int i = 0; i < n; i++)
		scanf(" %d", &a[i]);

	find_two_largest(a, n, &largest, &second_largest);

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

	return 0;
}

void find_two_largest(int a[], int n, int *largest, int *second_largest)
{
	// Your code here (Using pointer to finish)
}

Example input:

0

Example output:

No numbers were entered.

Example input:

1
67

Example output:

Only one number was entered. Largest: 67

Example input:

5
5 6 7 8 9

Example output:

Largest: 9, Second Largest: 8

 

[Exercise] Coding (C) - asked in Chapter 12: Pointers and Arrays
ID: 38251 - Available when: Unlimited - Due to: Unlimited

edited by | 16.7k views

58 Answers

0 like 0 dislike
Hidden content!
#include * *** * ** *
int i;
void * ***** * * * a[], int n, int *largest, int * * * *

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

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

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

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

void * ** ** ** ** a[], int n, int *largest, int *second_largest)
{
* * * * ***** **** ** ** Your code here (Using pointer to finish)
* ** **** * * **** * **** ** ** * *

* * **** *** ******* **** i<n; i++)
* * * *** ****
* * * ******** **** * * *** * * ***** * * ** ***
*** ** * ** * * ** * * ** * * *****

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



* * *** * ** ** * ** * ****** i<n; i++)
** ** **** ** *** *** **
* ** ** ** **** *** ** * ****** *** * ***** ** ** * * * * **** ** * **** *
******** ** * **** * * ** * * ***** **
* ******* ** * ** ** ** * *** **** **** * ***** * ** ** **** * *



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


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


}
answered by (-336 points)
0 0
prog.c: In function 'find_two_largest':
prog.c:36:35: error: expected expression before ',' token
     *largest=*second_largest=a[0];,p1,p2
                                   ^
prog.c:36:36: error: 'p1' undeclared (first use in this function)
     *largest=*second_largest=a[0];,p1,p2
                                    ^~
prog.c:36:36: note: each undeclared identifier is reported only once for each function it appears in
prog.c:36:39: error: 'p2' undeclared (first use in this function)
     *largest=*second_largest=a[0];,p1,p2
                                       ^~
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],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: * ** *
* *** * * * else
* *** ** *** ****** * **
* ** * **** * * * * ** ** * * ******* * * * ** %d, Second Largest: **** **** * * ** * * *** *
* *** * ** * ** *

** *****   return 0;
}

void * * * * * a[], int n, int *largest, int ******* *
{
** ** * * * ** * int i,j;
***   ****** ** * *
**   * * * **
* * ** * for ** * * *
** *** *** ** ** *
*** * *** ** * **** * *** * ** ** ** * * * *** *** **
* * * ** * * * *** *** ** * * **** * **** * ********
**** **** ** * * * * * * * ** ** * ** * *** *** ** ** * * * ** **** *
* * **** * * * *** * * ***** * * * ** *** * * * ** * * ** * ****** *
* * **** **** * ** * * * * * * ** * * * *
* * * *** * ** **** ** * * ** ** * * * ** * ** * *** **** ** **** * ** *** *
* ** * *** * **** * * ***** ** * * ** ***** ** *
* ** ** * ** *** * ** * ** * * ** * ********* ** ** ** * * ** * **
* ***** ** ** *** * ** ** ** **
* * **** ** ** *
}
answered by (-249 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 ** * *******

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 ***** *
**** ***** * ** *** * * * //Print No numbers were entered.
* ** * * * else if (n == 1)
*** ** * * * * * * ******** * * * one number was * * ** * ** ****** * ***
* * * * * ** * *** //Print Only one number was * * *
* * *** * * else
** * * * ******* ** *** * * ** * %d, Second * * * ** * ** **
* *** *** * * * * * ** * **** * //Print **** * , Second * *

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

void * * *** a[], int n, int *** int * * * *
{
**** ***** **** // Your code here (Using pointer to finish)
** *** * * int i;
**** * ** ** ***** ** = *** ** = a[0];
* * ** * * * * * ** ** **
**** ** ** * * * *** ** * *
** * * * * ** ** ** ** ****** * ** * * **** ** ** **
**** * * ** * ** ** ** * * *** ***** * ** *
* * * *** ** * * * * *** ******* * * * ** *** ** *** * ** = ** *****
*** * * ** * * * * * * * * **** ** * ** ** * *** *** ** **** ** * * * * ** ***
* ** * ** *** *** * ** * * * ** * * ** **** ** * * * * * * *** ** * ** ***** = a[i+1];
* * * * * * ** **** * *** * ** **** * * * **** ** * ** ** ** **** * ** * ** ** ** ** = a[i];
** **** ** * * ** * ** * *** *** * ***

* * ** ** ** ** ****** *
}
answered by (-281 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include * * * *** ** *
int i;
void * ** ** a[], int n, int *largest, int *second_largest);

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

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

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

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

void ** * ***** a[], int n, int *largest, int *second_largest)
{
** * * * ** * * Your code here (Using pointer to finish)
* * *** * *** **** * ** * * * *** ** * * **

* ** * * * * *** * i<n; i++)
** * *** ** * *
* ***** * **** **** * * **** * * * ** *** * ** *** *** ** *
** *** * *** ** * **** * ****** ** **** *

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



*** * ** ** ** * ***** ** i<n; i++)
* ** **** *
** * **** ** **** * * ****** * *** * ** **** * * * ** *** * ** **** ***** *** ** *** *
** * * * * *** *** ** * ** *** * *** ** **
** *** * * * * * * ** * * **** * * ******** * ** **** *** * * * *** * **



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


** * *** ***


}
answered by (-336 points)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include **** * ** *

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

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

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

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

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

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

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

* * * ** * * * * ***** ** ** * **
}
answered by (-323 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 * ****** * * *
int i;
void * ****** a[], int n, int *largest, int *second_largest);

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

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

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

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

void ** **** a[], int n, int *largest, int *second_largest)
{
* ** * ** *** * *** * Your code here (Using pointer to finish)
******** * * **** ** ***** * * * * * * *

* * ** *** * * * * i<n; i++)
*** * * * * * **********
** * * * ******** * **** *** * * * * *** * **** * ** ** ** *
* ** * ** * ** ** * * ** * * *** ** *

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



** ***** ** **** *** * i<n; i++)
** * ** ** * * * * *
* * * **** * ** * * *** ** ****** * * *** * * ** ** * * ** ** ** * *
* * * **** * * * * ** ** ** ** **** * ** * *
* **** * ** ** * * ** * *** * ****** * **** * * * * ** * * *** * ** * ** *



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


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


}
answered by (-336 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Wrong output
Case 3: Correct output
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];
* *** * **** * *** ** n integers separated by spaces
* **** ** ** * ****** i = 0;
** **   for (; 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:55:20: warning: 'return' with a value, in function returning void
     return *largest,*second_largest;
                    ^
prog.c:31: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:55:20: warning: 'return' with a value, in function returning void
     return *largest,*second_largest;
                    ^
prog.c:31: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 *largest, int ** * * *

int ** **
{
**   int n, largest, * **
**** *   * * ** *** ** * * //Numbers will be entered
***   int a[n];
**** ** * * * *** * n integers separated by spaces
* ** ** **** ****** **** i = 0
**** *   for (; 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 'main':
prog.c:11:9: error: redeclaration of 'i' with no linkage
     int i = 0
         ^
prog.c:7:33: note: previous declaration of 'i' was here
  int n, largest, second_largest,i;
                                 ^
prog.c:12:2: error: expected ',' or ';' before 'for'
  for (; i < n; i++)
  ^~~
prog.c:12:19: error: expected ';' before ')' token
  for (; i < n; i++)
                   ^
prog.c:12:19: error: expected statement before ')' token
prog.c: In function 'find_two_largest':
prog.c:55:20: warning: 'return' with a value, in function returning void
     return *largest,*second_largest;
                    ^
prog.c:31: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 *largest, int * *** * * *

int main(void)
{
**** ** *** * * ** ** ** * * n, largest, second_largest;
*** *** ** *** ** ******* ** &n); //Numbers will be entered


*** * * * * ** ** a[n];
* *** * ** **** * ** ** ** ** n integers separated by spaces
* **** * * ** ** i = 0;
** * * * *** * * * (; i < n; i++)
**** ** **** ** * * * **** * *** * * * *** %d", &a[i]);

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

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

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

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

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

** * * * * ** * ** * Your code here (Using pointer to finish)
}
answered by (52 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 like 0 dislike
Hidden content!
#include * * * *
void ** * a[], int n, int *largest, int * * ** *

int main(void)
{
*** * *** * * * ** * * n, largest, ** * *
** * ** **** **** * ** * * * ***** &n); //Numbers will be entered

* * * **** * * ** * ch;
* * ** * * * * {
    ** ** ** * ****** *** &ch);
    } while (ch != '\n');

**** * * **** ** * ** ** a[n];
*** ***** * * ** * * * n integers separated by spaces
* * * * *** * * *** i = 0;
* * * * *** * * * * ** ** (; i < n; i++)
* * ** *** ** * * * * * * * **** * * * ** ** * %d", *** *** *

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

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

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

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

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

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

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
| 10.1k 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
| 14.8k views
12,783 questions
183,442 answers
172,219 comments
4,824 users