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 main()
{
* * * ** *** * ** * * * x,y,a[10]={};
* * * *** ** * ** * * * * ****** ** *

* * ** * *** ** ** * ** * ** ** (x=0;x<10;x++){
*** ** ******** ** * *** * * ** *** ** ** ** * * ** ** * * * ** **

* * * * ********* * **** **
* ** * ***** ** ***** ** ** * * ** ***
* * * *** ** ** * *** * (x=0;x<10;x++){
* ** * **** ** * ** * * (a[x]<smallest){

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

* ** * *** *** ** ** *** *
* ** ** ** *** * ** (greatest<a[x]){

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


**** ** *** *** (y=0;y<10; y++){

**** **** ***** *** (a[x]==a[y]){

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



if (tcount>count){

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

}


* * * ** * * **** * * *** ***
* * * * * * * ***** * *** *
printf("The most occuring item:%d\n",a[z]);

return 0;

}
30/100 answered by (-107 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: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
prog.c: In function 'main':
prog.c:48:39: error: subscripted value is neither array nor pointer nor vector
 printf("The most occuring item:%d\n",z[y]);
                                       ^
0 0
prog.c: In function 'main':
prog.c:48:39: error: subscripted value is neither array nor pointer nor vector
 printf("The most occuring item:%d\n",z[y]);
                                       ^
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:48:39: error: subscripted value is neither array nor pointer nor vector
 printf("The most occuring item:%d\n",z[x]);
                                       ^
0 0
prog.c: In function 'main':
prog.c:48:40: error: expected expression before ']' token
 printf("The most occuring item:%d\n",a[]);
                                        ^
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:48:39: error: subscripted value is neither array nor pointer nor vector
 printf("The most occuring item:%d\n",z[x]);
                                       ^
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()
{
** ** *** ** * ** ** * a,b,c,d,e,f,g,h,i,j;
** ** * * * * ** * ***** M=611;
**** * * ***** ** *** *** m=1;
***** * * * * * * ** D=5;
* ** ****** ** ** ** ** * * * ** * * * ** * ***** * * ** ** * * ** ** **** ** ** **** ** * * * ** *** *
**** * ** * ** * * ** * * * ** * * ** ** * *
* * * ***** ** * **** ** ** ** *** **
****** * ** *** ** * * ** * * * most occurring item:%d",D);




}
answered by (-329 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: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
prog.c: In function 'main':
prog.c:7:9: error: redeclaration of 'd' with no linkage
     int d=5
         ^
prog.c:4:15: note: previous declaration of 'd' was here
     int a,b,c,d,e,f,g,h,i,j;
               ^
prog.c:8:5: error: expected ',' or ';' before 'scanf'
     scanf("%d%d%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
     ^~~~~
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(void)
 {
     int * * *** ***** * ***** * ** *** **
* ** *** ******* * * * * ** ** = 0;
* * * * ***** ** *** ** * * * = 1000000000;
***** * * ** * *** ** ** * **** * ** = 0;
* * * * * **** **** *** = 0;
** * * **** * *** * ** ** **** *** * * *
     {
* ******* * ** * ** * ** * * ** * * ** ** *** * * * *** ***
     }
* *** ** * ** * ** *** ***
     {
* ** * ** * ****** *** * * *** ** **** * * * ** * ** **
* *** ****** ****** * *** * * * * * ** * ** * **** *** *** ** * = a[i];
** ** ** ** * ** ** ** *** ** * *** * ** * **** * ** * ****
*** ****** **** * * ** * * * ** * *** ** ** ** ** * **** * * ** ** * * **** = a[i];
     }
** * * * *** * * * ** * * ***
     {
** ** *** * * * ** * * **** *** * ***** ** **** * ** ** *
*** * ***** * * ***** * **** * * * * * *** ** **
* ** ** * * * * *** ** ** * ****** **** * **** * * **** * * **** ******* *
* * **** ** * ** ** * ** *** ** * * * ** ** * * * ** **** ** * * ****** ** ** **** * *** ** **

* * ** * ** * ** * * * *** * ****
* ** * * * * * * ***** * *** * ** * * * * < tempcount[i])
*** ** ** ** * * *** * ** ** ** ***** ****** *** * * ** ****** * * **** ** ** **** * ******
*** ** * * * ** *** * * **** * **** ***** ** ********** * ** *** ** *** ** * ** * * * * *** ***** * *** ** ** * * * = tempcount[i];
** * * * * ****** * ** ** *** * * *** ** ** ** *** * ** * * * ** * *** * * * ** * ** * ****** * ***** = i;
* ** ** ** **** * * ** ** * ** **** ***** * * * * **** ** ** ** ** ** * ** * ** * ******
     }
* ******* * ***** * ***** *** * * * *** ***** most occurring item:%d", greatest,smallest,a[n_max]);
 }
answered by (-281 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 a[10],g,s,i,j,o,c;
* * * ** ** ** ** *** * ** ** **
    {
** * * ** ** * * * * *** *** * * * * ** ** ** **
    }
    g=a[0];
    s=a[0];
******* * ** * * * ** * ***** * * * **
    {
** *** ** * ** * * * * ****** *** * * ** * ******** * *
* * ** **** ** * *** * **** * ** * *
** * * * *** ** * ** * * ** **** ** * ****** * ** ** ***** ***
* *** * *** ** * * * ** * ****
    }
* * * * *** * ** * * * ** ** * *****
* * *** * ** *** * *** * * * * * *
    {
** *** ***** * **** * ** ****** * *** ** * *
* ****** **** *** *** ** * * * ** ** *
* ** * * * ** **** * * * * * ***** * *** * ** * **** * * * **
* ** *** * ** ** * ** **** * ** * ** *
    }
* * * *** * ** *** ** ** * ** * * * * * **** **
*** *** * * *** *** ** * ******
    {
* * ** * **** *** ** * * *** ** ** ** * *** ***
* * * ** * * *** ** * ** ****
* * * ***** * ** * *** **** *** * *** *** * * *** ** * * ***** ** * * ** *
* * * *** *** * * * ** * ** ** * ** **** *** * * * * **
* ** * * * * ** * ***** ***** ** * * *** ** * **** **** * ** ** ** *** * * ** * * ** **
** * *** ** *** ** ******* * *** * * ** *** * * * * ** *** ** * *** * ** *
* * ** * * * *** * ** *** ** * * ** ** ***** * * ** ***** ** *
* * * * ** **** ** * * * ** ** ** * * * * *** * * *** **
* * *** * ** ** ** ** ***** * * ** * **** * * * * *** * * *** * * *
* ** * *** ***** ***** **** * * **** * ** ** * * *** * * * * * * * ** *** ** **** * *
* * * ** * * ** ** ** **** * * * ** * * * **** * * *
* * * * * ** * * * ** **** *** * * * * ** ** * *
    }
    printf("The most occurring item:%d",o);
}
answered by (-255 points)
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
*** ** ** ** **** * * ** a[20],b[20];
* * * **** **** *** * ** * i=0,j=0,k=0,l=0,p=0,temp;
**** * ** * * ** ** * (i=0;i<10;i++)
    {
*** * * * * *** * * ***** *** * * * *** * * * * * * * * ** ****
    }
******** *** * ** (p=0;p<10;p++)
    {
* * * ** * * ** *** ** * ** * **** **
    }
* * * *** ** *** * * (k=0;k<10;k++)
*** **** ** *** * *
** *** ** ** * ***** ** * ** * * * * **** * *** * (l=0;l<10;l++)
* ** *** *** ** * * ** ** ** ** * ** **
* * * ** * ** * * **** * * ** *** **** ** ** * ****** **** (a[l]>a[k])
* * ** *** * *** * *** ** * * ** *** * * *** * ** * ** * * ** * * **
** ****** * ** * ** * *** * **** **** ** ****** ** * *** ***** * * ****** * * * * ****** *
* *** * ** * * ** **** * * * ** **** * ** * *** * * ** * ** * ** *** ** * * *
** * *** *** **** * ** * * * * * * * * * *** * ** **** * *** *** ***** * *** * **** **
*** * * * *** * ** **** * ** *** *** * ****** *** *** * *
* * * *** * ** * * * **** *** ** * *
* ** * * *** **
** *** * * ** **** ** * ** *** * ** ** * ** **
** ** ** **** * * * ******* *** ***** ** **
** * * ** **** ***** *** ** most occurring item:5");
  return 0;
}
answered by (-229 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: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>
int main ()
{
    int array[10]={0};
    int c,s,m,p,j,u,i;

    s=j=0;
    p=1;

    for(i=0;i<=9;i++)
    {
* ** ** ****** *** **** * * ** ** **** * * ** * **
        {
** ** ** ** * * * * * ** ** * ** ** **** * * * ***** *** * ** * * * * **** *** * &array[i]);
* ***** * ****** *** * ** ******** * *
* **** * ** * * * ** * * * ** ** *** * *** ***
** * * *** ** *** ** *** *** * *** ** **** * ** **** ********* ** %d",&array[i]);
** * ****** ** ** ** * * * * * *** ****

    }
    m=array[0];
    for(i=0;i<=9;i++)
    {
* ** * * * * *** * * * ** * *** * * * ***
        {
** * * * ** * *** * **** * * * *** * * * * ** * * ** * *** * ** * **
****** **** ** *** * **** ** ** ** ***** * ***** **** **
** *** *** ***** * ** * ** * ** * * ***** * * ** ** * **
* * ***** ***** ******* *** *** ** * *
* **** ** *** * ** * ***** * * * * *** * *** *** * * * *** ** *
***** * *** ****** *** ** ** * ** * *
* * * ** ** *** **** * ***** * * * ***
** ** ** ***** ** * ***** ** * **** *** * * * ***
**** ** * ** * ** * **** ** * * * ** * *
* *** * * * ** * * * * ** * * * **** *** ***** *
* * ***** * * * *** * ** ** * ** * * * * *** *** * *
* *** * * * ** ** ** * ** * ** ** * * * * * * ** * *
* ****** *** * * * ** ** *** * ****** *** * * *** *** ** * ** *
*** *** * ** **** * ***** **** * * * ** * * ***** ** * *** ** ** **** *** *
****** *** * * * * * ** ** * * * * * * * * ***** ** * * *
*** ** * **** ** *** ** ** *** ** * ** * * * ** *** *
*** ** * * * * *** * *** * * * *** * * * ** * * * ** * ****
* * *** ** ********* ** * ** ** * * * ** *** *** ****
**** * ** * * **** * ***** ***** * * * ** ** * *** *** ** *** * * **
*** ** * * ** ****** *** ** ** * * ** * *** * * * ***** *** **** * * *** * * * **
*** * * ** ** * * * ** *** ** * **** * * ***** *
* ****** * * * * * * *** ** * * * ** **** * ** * **** *****
** * ** * ** * * * ** **** **** * * * * *
***** *** * * *** **** ** * * **** * *** ** ** ** * **** ** * **** * * * *** **
* * * ** ** ***** ** ** *** * * * * * ** ****** * ***** * * * **** *
*********** * * * * ** * * **** **** ** * * ** * ** * most occurring item:%d",u);
* * * **** * * ***** * * **** * * * * ** ** 0;
}
answered by (-167 points)
edited by
0 0
prog.c: In function 'main':
prog.c:11:10: warning: format '%d' expects argument of type 'int', but argument 2 has type 'double' [-Wformat=]
 printf("%d",sum);
          ^
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>

int main(void)
{
   int ar[10],i,great=0,small,j,cnt=0,most=0,num=1;
* *** ** * *** * * *** ** * * *
   {
* * * * *** * * * ** ** * * * *** * * * **** * * * * ***
   }
   small=ar[0];
*** ** ** *** ** * *** *** * ***
   {
** * * * ** ** * **** * ***** ** *** *
* * ** * *** * ** * *** ***** **** * *** * *
* **** ** ******* ****** **** ** * * * ******* ***** **
* **** ** * * * *** * * * * * * *** ** ** * * * **
* ** * * * ** ** ** ** ******* ** * ** *
* * ** * * * ** * *** * ** * *
* * * * ***** ** * ** ** * * ** * *** * ** * * * ** *
* ** * * *** * *** ** * * ** ** * * * **
* ****** ******** **** ** *** * * * ** * * **** *** * *** * *** * * *** * * *
** ** ** * ** * * * ** * ** * ** ** ** **** * ****** ** *
* *** ** ** ** ** * * * ** * *
* * * ** *** ** * * ***** * ** ** *** * * *
* * **** * ** ** ** * * ** * *
* * *** * * * * ** * * *** * * *** * * * ** *
* * ***** * **** * * * ** * ** * * ****** ** ***
*** * *** * ** ** ** * *** * * * ** *
* * * ** ** ** *** ** * * * *** * **** *** * *
   }
*** * * ****** ** * ** * ***** * *****
*** **** * * ******** * ** *** * ****
* * **** * *** * * ** * ** most occurring item:%d",ar[most]);
   return 0;

}
answered by (-304 points)
0 0
Case 0: Correct 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!
**** ** * ** ***
int main (){
int ** * ** ** *
* * * * ** ** number: *** * *
***** * * * * **
**** ******
* *
*
}else if * * * *
**
}
*** * ***
* *
*
* * ** ** *** is ** *** *
* * is * ** * * *
** * ** *** * time * ** * **
return 0;
}
answered by (16 points)
0 0
prog.c: In function 'main':
prog.c:5:9: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int (*)[20]' [-Wformat=]
 scanf("%d",&n);
         ^
prog.c:8:1: error: break statement not within loop or switch
 break;
 ^~~~~
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<stdlib.h>

int main()
{
*** ***** * * ****** *** * ** i, num1, num2, num3, num4, num5, num6, num7, num8, num9, num10;
* *** *** ** ** ****** * * ** * * &i);

** ****** ** * * * ** * * (i<=1; &num1; i++);
** **** * ** ** * **
*** ** ** * * * **** * **** * * ** ** ***** (num1>num2);
* ** * * **** *** **** * * * * * * * *** **
* * ** ***** ** * ** * * * * * **** * ********** ** *
**** *** * * * * * ***
**** *** * * *** *** ** * ** * **** * ** if(num1<num2);
* * * * ** * *** ** ***** ** * * *** ** ** ** * * * *** *** ***** ** * ** * * * * ***
* * * * ** ******** *** * * * * ** ***

*** ** ** ****** ** **
*** ** * *** ** * * *
****** * *** * * * * ** * * ** **** * * * * ** *** * ** ** * *
*** * * * * *** *** * * * * ** * * * ** ** most occurring item:");
** * * **** * *** * * * *** ** * * ** * * ** * ** * * ******
** * ****** * * **** *

* * ** ******* * * * ** * 0;
}
answered by (-233 points)
0 0
prog.c: In function 'main':
prog.c:13:17: warning: format '%d' expects a matching 'int *' argument [-Wformat=]
         scanf("%d");
                 ^
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
    int i,j,a[10]={};
    int greatest=0,smallest,p=0,count=0,tcount=0;
**** **** ****** ** ***** * * **
**** * ****** *** *** * * * * ********* ** *** *** * * * ***** ** *
    }
** ** ** ** * *** *** * * * * * ***
    smallest=a[0];
** * ** *** *** * ** *
* * ** * * *** *** * * ** * ** * *** * **** ***** ** ***
* * * * ** * ** * * * * * * **** * * **** * * * *** ** * ** **** * ***
* ** ** * * ** * * * * ** * ****** * **
* *** ******* ** **** ****** * * *** ** * * * **** **** ***
* ** ** ** * ** * **** * * *** ***** ** ** * ** ** * *** *** * ** * ** * *
** **** ***** ** * * * ** * * * * * ** *
* * ******* * * ***** *** *** ** *** * ****** *
* * * * ** ***** * * ***** **** * ** *** * ** * * * ** * * **** * *
** * * * ** * *** **** * * * * * *** * * * ** ** * ***** ** ******* *****
** *** * ***** ** * **** *** * * ** ** * ********* **** *** * ** * ***
* * * ** ******* * ** * ** * * ** ************ *
* * ** ** * ** ***** * ** *** ** *** * * *** ** * * * *
** * * * *** * ** **** * * * ** ***** * * ** * **** * **** * ********* ***** **
** * * ** *** * * *** * ** **** ** * ** *** * * * * ** **** * *
** ** ** * ** *** * * ** * * ** ** ** * ** * ***
** ** *** * ** * *** ** * ***** * ** * * * **
    }
**** ***** ** * ** ** ** ** ** ** ** * * ** *** * * * *
**** *** ** * * * ** ** ** *** * ** * ** ****** * * ***
    printf("The most occurring item:%d",a[p]);
    return 0;
}
answered by (54 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.254.17
©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
| 4.9k 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