1 like 0 dislike
5.1k views

Write a program that will prompt the user to input ten integer values. The program will display the smallest and greatest of those values. It also displays the value that occur the most.

寫一個程式 輸入十整數 找出最小值、最大值、眾數

Example input:

100 5 5 7 89 62 54 611 1 87

Example output:

Greatest:611
Smallest:1
The most occurring item:5

 

Example input 2:

100 5 5 7 7 62 54 611 1 87

Example output:

Greatest:611
Smallest:1
The most occurring item:5
[Exam] asked in Final Exam
ID: 42302 - Available when: 2018-01-17 14:00 - Due to: Unlimited

retagged by | 5.1k views

37 Answers

0 like 0 dislike
Hidden content!
** * * ** * *****
int num[10],s[10];
int i,j,min,max,many,smax;



int main()
{
* * * * **
{
** * ***** * * ** * * ** * ** ** ** **
}
// ** ** ** * ** * * * * * ** ***

max=num[0];
for(i=0;i<10;i++)
{
* ****** * *** ** *** ****** * * * ***
**** *** * **** ** * ** (num[i]> max)
** * * *** * * *****

* *** * * * * ***** *** * * ** * * * **
** * ** **** *** * * * *
}

min=num[0];
* * ***** * * **
{
*** * ** ** * * * * * *** (num[i]<min)
***** ** * * *** *
* *** * * ** **** *** ** ** * ** * ** ****
* * * * * ****
}

*** * **
{
*** * * ** * * ***** * *
}

* **** ** ****
* ** * ** *** **
{
**** ** * **** ** * ** (num[j] == num[i]  )
* ** ***** * **** *
* ** ** * * *** * ** *
* * ******** ** *** * *
}

}


smax=s[0];
**** *** **
{
* ** * * * **** * (s[i]>smax)
* * ****** *** ** *
* ** ** * ** * *** *** ** ** ******* ***** * * *
**** * * * * * ****
}

for(i=9;i>=0;i--)
{
* *** ** *** * *** (s[i]==smax)
** * ** * * ***
* * * * * ** * ** * * ** * ***** * *
****** ** ** ** * * **
}




* ** * * * * * ** * * **** *** ** * *** most occurring ****** ** * * *










}
answered by (-336 points)
edited by
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: 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!
* ** ** * ***** * *****
**** ** ** ***** *

int main()
{
* * ** a[10];
 int z, max, min, x, c=0, p;
* **** *** * **
 {
**** *** *** ** * ** ******** **
 }
** *** ** *
* * *** * *** *
 {
* * * * * *** ** *******
* ***** ****
*** ***** * * ** * *
* * ** **
 }
** * *** * * * ** *** ** ** *
*** ******* * * *
* ** * *** ** * * *
 {
* ** * * * **
* * * * *** *
* *** * ** * ******* * **
* *** * * *
 }
* *** * *** * ** * **
 int b[10]={0};
** ** *** *** * **
 {
** ******* **** * * * ***
****** * ** *
***** * *** *** * * *
**** **** * **
* ****** * *
 }
** * **** * * **
 {
** * ** **** * *** **
** *** **
*** ***** ** ** * * ***
*** * ** *** *
** * *** *
 }
* * *** * most occurring *** *** * *

* * * * *** 0;
}
80/100 answered by (-66 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)
{
    int cpt,j,s,p,m,u,i;
    int tab[10]={0};
    s=j=0;p=1;
    for(i=0;i<=9;i++)
    {
** ** * * * * ********* * ** ***
** * * ** ** *** ** * * * **** ** * ** * * **** * *** * &tab[i]);}
* * **** * ***** * * * * *** ***
*** * * * * * *** ** * *
** * **** * ** * * * * * * * *** ** **** *** * * ** * ** * ** %d",&tab[i]);
** ** *** * * ** * ** * * * * ***** * **

    }
    m=tab[0];
    //for(i=0;i<8;i++)

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

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

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

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


    }
    //for(i=0;i<8;i++)

** ** ** ** **** ***** *** * ** * ****** ** * *
* ** ****** * * ** ** *** **** ** ** * **
*** *** *** **** ** * ***** * * * *** ** * ** * * * ** ** * ** * * ** ** * *** *
***** * * ** * * * * * *** * ****** ****
* *** *** * * * ** ** ******* ** ** ** (tab[i]==tab[cpt])
**** ** * * ** * * ** *** * * ** ** **** *****
*** ** ** ** *** * **** **** **** * *** * * * ******** * ** * ** **
* * * * *** ** * * ** ***** * *
*** * * *** ** * ** * * ** **** * * ** ** **
** ****** ** * ** ** ***** * * * *
******* ** * * *** * *** *** * ****** *** *** ** * * ** *** *
*** * * ** ** *** *** ***** ** * * * * *** * **** *** * ** ** ** * *
* ** ** ** *** * * * * * * * * * *** ******
* * ** * * * ** *** * ** *** * * * *** *
*** **** ** * ** ** * * * * **** *
** * **** ** ** * * * **** * *** ** ** * * * * **** ** * ****** *
* * * * *** * **** * * ** ** **** ** *** * * ** * * * *** ** **** * *
* * * * * * ********* **** *** ***** ** ** ** * * * * most occurring item:%d",u);
******* * **** * ** ** * * ** ** * *** * ** ** 0;
}
answered by (-168 points)
edited by
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: Wrong output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include *** ** ***
int main ()
{
* * *** * ** *** * *** * ** ** ** *
* * *** * ** ** ** * *** ** *** ***

* * ** * * ** * * ** ***
* *** ***** * ** ********** *
**** ** * *** most occurring item:5");
*** * *** * **** * * 0;
}
answered by (-32 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
prog.c: In function 'main':
prog.c:7:8: warning: missing terminating " character
 printf("Greatest:611);
        ^
prog.c:7:8: error: missing terminating " character
 printf("Greatest:611);
        ^~~~~~~~~~~~~~~
prog.c:8:8: warning: missing terminating " character
 printf("Smallest:1);
        ^
prog.c:8:8: error: missing terminating " character
 printf("Smallest:1);
        ^~~~~~~~~~~~~
prog.c:9:8: warning: missing terminating " character
 printf("THe most occurring item:5);
        ^
prog.c:9:8: error: missing terminating " character
 printf("THe most occurring item:5);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.c:10:3: error: expected expression before 'return'
   return 0;
   ^~~~~~
prog.c:11:1: error: expected ')' before '}' token
 }
 ^
prog.c:11:1: error: expected ')' before '}' token
prog.c:11:1: error: expected ';' before '}' token
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: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main() {
    int a[10],o[10];
    int i=0,g=0,s=0,o1=0,o2=0,j=0,c=0;

* * ** *** ** * * * *** * ***** **** {
** *** ********** * ** * * * * * ***** ** *
*** * ** * **** **** * *** **** **** * * *
    }

** * * * ***** * * * ***** {
* * ****** * * * * *** * * **** ** * ** ** ******* ** ** &a[i]);
    }

    g=a[0];
** * * * ** ****** * * *** * {
*** * *** ****** * * *** * * * *** * *** *** * ** * ** {
****** * ** ** ** ** ** *** ** * ** ** * * ** *** * *** * ****
* * * ** *** **** **** * * * *
    }
** ** * * * * *** * * * ** * * ** * * * g);

    s=a[0];
**** * * **** **** * ** * {
* * * ** ** *** ** *** * ** * *** * * * * * * **** ****** {
**** ******* * * * ** * * **** * * **** **** *** * ** *** *** ** *
**** * ** ** * ** ** *** ** ** * * **
    }
* * * **** * ****** * * * ** ** * ***** *** s);

** ****** * * **** ** * *** ** ** * * * {
* * * ** ** * ** ** * ***** * *** ** * * * * {
*** * * * * ** * * ** ** **** * * * * * *** * *** * *** ***** * ** *** *** {
*** * ** * *** * * ** ** * *** * *** * *** * * ** *** *********** * * ** * * ** *
* * *** *** * ** * *** * ** * **** ** * *** * * *** ***
***** * **** ** * ** * * * ** *
* *** * ** ********* **** * ** *** ** ******** * * * {
********* *** * * **** ** ** ** **** * * * * * * ******** * ** *** * ********
* ** * * * * * *** * *** *** ** * ** * *** *** *** *** *
** *** * ** ** *** * ** *** **** * * ** * **
** * ** ** ** * *** * ** ** ** *
    }
* * * ******** * * ** * most occurring item:%d", a[c]);
}
answered by (-120 points)
edited by
0 0
Case 0: Wrong output
Case 1: Correct 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
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()
{
    int a[10]={0},max=0,min,i,count[100]={0},most,j,n;
    for(i=0;i<10;i++)
******* ***** ** * * * ** * ** * **** * ***
*** ****** * ** ** ****** * * ******* ** ** *** * ******* ** *** *** * *** * * * * ***
** ** ** ** * ** **** ** ** **** **** * * *
    max=a[0];
    min=a[0];
    most=a[0];
    for(i=0;i<9;i++)
* ** * ** * **** * * ** ******* ** * *** * *
* ***** * ** *** ** * **** * ** * ** * * * ** * * * ** **** max=a[i+1];
* * ** ** * **** * * **** * ************ ** ** *
** * * *** * ** ** ** * * * ** ********** **** ** * *** * *** ****** ** *
** **** * * ** * ***** ** * * * *
** * ****** ** ** * * ***** *** * ** ** * *
*** *** * ** *** ****** * * ** ** *** * ******* * *** ** * * ** * * **** * min=a[i];
* *** ** * ** *** * ** *** ** * ***
*** *** * * * * *** * ********* ** * **** * * * * ** ** *** * ****
    for(i=0;i<10;i++)
** * ** * * * * *** * * ** * **** **** * * *** **
** * ** ** * ** ****** *** * * * ** *** *** * * *** *** * **** ***
* * ** ***** * ** ** *** * * * ** * * ** * *** * ** * * ** *** * * * *
*** * ** **** * * ** ** ** * **** * * *** * *** * ***** *** * ** ** ** **** * * * ** ** ** ** * **** == a[j]) count[i]++;
** ** * *** *** **** * * * * ** * * * ** *** * ** ** * ******* * *** * * * * *
** ** ** ********* * ** ****** *** * ** * * ** ** * **** * ** * ** ** *** * * * *** * *** *** * * *
** * ** **** * ** **** ** * * ** *** **** * *
    //n=count[0];
    for(i=0;i<10;i++)
* * * * * ****** ** * **** *** ***** *
*** * ** *** * * * * ** *** * * ** ** ** ** ** *** *** **** ** * *** ** **
** **** * *** * *** ** * ** ***** * **** * * ** ** ********* ****** ***** ** * *****
** ** * ******** * * *** * * * * * * * ** **** * ** ** ** * * * ** ** * ** * * ** ** ** ** * * * *
*** * ** * **** ** ** * *** * **** *** *** **** ** ** *** * ** * * * *** ******* * * ***


* * *** * **** *** * * *** * ** * * * ** *
** *** *** *** **** * ** ** * most occurring item:%d",most);
}
answered by (-301 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: 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
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>
#define N 9
int main()
{
* * ** *** * **** *** a[N],c, i, temp[1], count, flag;

* **** *** * * ** **** ** ** c<N; c++){ ** ** *** *** * *** ** * ** * * **** numbers in array
* ******* * **** *** * * * * * * ***** *** ** ** * ******** **** &a[N]);
** * * ***** * * *** *

* * ** * * ** * * ** i<N; i++){ ** * *** * * ** * * * ***** * ** * ****** ** * the array Largest to Smallest
* *** ** * *** ** * ** ** ** *** * **** > a[N+i]){

**** ** ** * * * **** ** * *** *
* * * ** ** *** *** * * * * ******
* *** * *** ** ***** * ** * * *** ** * *
** * ********** * **** ** ** ** * *** * *** * **** ** ** * ** ** * ** = a[N+i];
******* *** * * * ***** * * * *** ** ** ** * *** ** * * * **** = a[N];
*** * ** * *** * * ** ** * * ** ** *** *** * ** ** * ** *** *** = temp[1];
* * * * *** *** **** ** * ** ****
** ** * * * * * * * **** *
//Therefore Largest must bes first and smallest last so print postions of the array
*** * ** * ****** **** * *** *** * * *** **** a[0]); //Greatest in First Position
* *** * * *** * *** **** * ** * * ** a[9]);//Smallest in Last Position

* ***** ** ** ** * * ** * * * ** * i<N; i++){ ** ** * ** * *** ** * * * * values next to each other since the list is already sorted
** ** * * * * * ** ***** ****** ** ** == a[N+1])  // Reoccurring numbers will be next to each other
** ** * * * * ** * **** *** ***** * * * ** ** * *
** * * * *** ** ** * ** * **** ** *** * ** * *** * ** **** * *
* * **** * ** ** *** ** * ** * * * **** * **** * *** * * ** == 1){
* * * ** ** * * *** * * * * ****** **** ** * * ** * * ** ** * * ** *** *
** ** ** * * * * ** * *** ***** * ** ** ***** * ***** * **** *** ** * **
** * * ** * *** * *** **** * ***
* **** * ** ***** * * * * **** **** **
*** * * * ** * ** ** ** * * * * ** **** *
*** * ** * * * ** * * ** ****** ** **** ** ** ********** * * ** *
***** *** ** *** * * ** * * * ** * * * * **
**** **** * * * * *
* * ** *** ** * * * *** * most occuring item:%d", a[N]);// Will be where count has inceamented the most!
* * * *** * * * * * 0;
}
answered by (-168 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>
#include<stdlib.h>
#include<string.h>
#define n 10
int  main(){
** ** * **** * * *** * a[n],k[n]={0};
*** ** * ** ** * * i,j,Greatest,Smallest,most=0,occ;
**** * * * * ********* * * ***
* * ** **** * * ** *** ***** ***** ** * * ***** ** * * ******
    }

* ****** * ** **** ** *** ** *
* *** * * ** * ** * **
* *** ** * * *** ***** ***** (i=0;i<n;i++){
* * * ** * * **** *** * * ** ** * ****** * *** ***** *****
* * * ** ***** *** * **** * * ********** ** ** * ** ** ** ** ****
** * * ** ** * ** * **** **** ** ** **
* ** *** **** *** *** * * * ** ** * ** *** ** *** * *
* * ** ****** * *** *** * ***** * ** ** *** ** **** * * * * ** ** *
** ***** ** * * ** * *** * ***** * * * * * *
* *** *** * ******* * ** * * * * * *** ** *
* * * ** ** *** *** **** ** * ** * *** * *** ****
*** ******** ** ****** * * * * * *** ********* **** * * *** *** ** * * **
* * ** **** * *** ** * * * *** ** **** * ** ** *** *** * * * * * **
* * ** * * ***** ** * ** * *
    }
* * * ** ** * *** * (i=0;i<n;i++){
*** * ** * **** ** ** * * *** ** ** ** *** * ** *
**** ******** ** *** * ** * * * * * ** * * **** ****** * * * ** *
* * ** * ***** ** * ** *** * *** *** *
    }





**** ** ** * * * ** * * * ** \n",Greatest);
*** ** ** * * *** *** *** ** * **** ** \n",Smallest);
*** *** ****** ** *** ** * most occurring item:%d",occ);
** **** * ** ****** * 0;

//100 5 5 7 89 62 54 611 1 87


}
75/100 answered by (-32 points)
edited by
0 0
prog.c: In function 'main':
prog.c:9:16: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'char *' [-Wformat=]
        scanf("%d",&a[i]);
                ^
prog.c:33:5: error: expected declaration or statement at end of input
     printf("The most occurring item:%d \n",occ);
     ^~~~~~
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
prog.c: In function 'main':
prog.c:38:5: error: expected declaration or statement at end of input
     printf("The most occurring item:%d ",occ);
     ^~~~~~
0 0
prog.c: In function 'main':
prog.c:38:5: error: expected declaration or statement at end of input
     printf("The most occurring item:%d ",occ);
     ^~~~~~
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>
#include <stdlib.h>
int * * * ******** * *

int main(){

** ** * ** ** * * ** ** * ** * ** **
* *** * ** * * * ** ** * * *** * * * ** *** * * * *** *
    }
* **** ******* ** * * * * ** ** ** ** * *
***** * ** **** ******** ** * * *** *** * * *
    }

    greatest=in[0];
** * ** * ** ** * ** **** ** * ***
* *** ** ** * * *** ** ** * *** **** * ** ** * * * * * ** *
    }
* * *** ****** * ** * * * *
***** * * * ** ** ******* *
*** * * * **** ** ** * * ** *** **** * ** *** * ** * ** ***
    }


* ** ******* **** ** *** * ***** *
* * * * * * ** * * * ***** **** * ****
* ** * * * * ***** * *** * *** ** * * * ** * *** **** * * * * *** * ** *** * ** * **** ** * * **** *** * * **
* **** **** **** ** **** ** **** **
    }
** ****** * * ** ****** ** * * *
* ** **** ** * ** ** **** * **
***** * * * * ******* * ** ** ****
* **** **** * ******* *** ** * *** * * *** * * *** **
** * * ******* ****** * * * * ** * * *** * ** * *** * ** **** ** ** **
* ** * *** ** * * ** * ** * ** * * ** ***** * * ** * ** * *
** * * ** * * * ** ** * ** ** ** * * ***

    }


* * * * ** ** **** ** ******* *** * ** ** * * **
** ** *** ** **** * *** * ********** *** ****
** ** * **** ** ******** * * most occurring item:%d",popular2);
    return 0;
}
answered by (-286 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(){

*** * * ***** ** * ** * * int MAX = 10;

    int num[MAX];
    int i;
* * ** *** ** * *** * *** * * G=0;
* * * * ** *** **** * * S;
    int item=0;
* * * ************ j;

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

* * *** *** ** ******** Smallest from first int in the array

** ** ** *** * * * ***** * * * ***
******** * * * * *** * **** * * * ** < num[i])
* *** * ** *** *** *** * * ** **** * ** *** *** ** ** ** * *** **** = num[i];

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

* ** * ** ** * ** ** * * * ** * * *** * * * ** **
* ** * ** * ** ***** * * ****** **** **** * **** * * * ***** * * * ** *
** * * * * * * ** * ** ** * *** * * * * ** * * *
* ** ** * ** * * **** * ** ** *** * * * ** ********* ** ** * * ** *
*** *** *** * * ** *** * * * * * *** ** *** * ***** * ** * ** ** ** ** *** *** ** *
* *** **** ** ****** * * *** ** ** * **** ** * ** **
    }

* * **** ***** ** ****** ** ** * ** ** * G);
** * * * * ** * * *** * * **** ** * ** S);
** * *** * * ** * ** * ******* * * most occuring item:%d",item);

** ** * * * * ** * *** 0;
}
45/100 answered by (-74 points)
0 0
Case 0: Wrong output
Case 1: Wrong 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:172.70.130.42
©2016-2024

Related questions

2 like 0 dislike
31 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42301 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 4.5k views
1 like 0 dislike
32 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42300 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 4.8k views
1 like 0 dislike
37 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42299 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 5k views
2 like 0 dislike
30 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42298 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 3.8k views
0 like 0 dislike
13 answers
[Exam] asked Jan 19, 2018 in Final Exam
ID: 43463 - Available when: 2018-01-20 09:00 - Due to: Unlimited
| 1.6k views
12,783 questions
183,443 answers
172,219 comments
4,824 users