1 like 0 dislike
1.8k 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 | 1.8k views

37 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
    int a[10]={0},M=0,m,i,c[100]={0},most=0,j,n;
* * *** * ** ** * ** **** * ** *
    {
**** ***** ** * *** * * ** * ** * *** ****** ** *** * **** * *****
    }
*** ** * * * ***** * **
* *** *** *** ***
* * * ** * ** * ***
    
* ** ** * *** **** * *** ** ** *
    {
** * * * * * ******* * * ** ** * **** * * * * *
**** * * **** ** ** *** * ** * *** * *****
*** * * * * * ** ******* * ** ** *** ** * ** * ******** * ***** **
*** ***** *** ** * ** ** * * * ** * * *

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

*** * * ** * * * ****** *****
    {
******* ** ** ** ** ** ** * ******* * * **** *
* *** * **** * * * * *** * ** ** * * * * *
* ** * * ** * * ** * * * * ** ** *** * ***** * ** * ** ** ***
** * * * * * * * * **** *** * *** *

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

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


*** * * *** ** * *** ** ** * *
    {
** **** * * ** ** * *** ** * * ** * ** **** **
* * * * ** ** * ** * *** ** * *** * *** ** * *
* **** * * * * * ** * * * ** ** ** ****** ** * *** * * * *
*** ** **** ** ** ** * * * ** ***** **** * * ***** ** ** *** * * **
*** * * *** * * ** * * * * *
**** ******* * * * * * * * * * * * ** if(c[i]>c[i+1])
* *** ** * ** **** * * * * ** **** * * * *
*** * * * * * * * * **** *** * *** * * * ******** ** ** * *** * ***
* * * * * * * * ** ** * * ** ***** ** ** *** * * ** * *** ****
** * ****** * * ** * * ** ******** * **
    }


* **** * ***** * * ** * * * most occurring item:%d",most);
    return 0;
}
75/100 answered by (-249 points)
edited by
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Correct output
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: 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 like 0 dislike
Hidden content!
#include <stdio.h>

int main(){
    int a[10],b,min,max,most,c[10]={0},d,e=0;
*** * * *** *** ** * * *** * * ***** *
* * * ** *** * * * *** * *** * *** **** * * * * ** ** * * **** *
    }
    min=a[0];
    max=a[0];
* *** * ** ***** * * * *
** *** *** * * *** * * * *** *** *** ** ** * *
* *** ***** * * ** * *** * *** * ** * *** **** * * * *** * ** * **
* **** * ** ** * ** *** ****** * * * * * ** ** * ** *** * * **
* * * ** ** * * ** * * * ***** * * * * * ** * *
* **** **** * ** * ** * * ** ** %d",max,min);
*** * * * ** **** * *** * ** *** ** ***
* ** * ** *** * * * * *** * * **** *** ** * *** * **
**** ** * ** ** ******* ** * ** ** **** ** * ** * ****** ** **** * ***
** ** * ** ** *** ** * * * * * * ** ** ** ** *** ** ** * ******** * ** ******* *
** ** * ** **** * * ** ** ****** ** * ** * ** *
    }
** ** ****** ** ** ***** * * *
** * * * * ** * * * ****** ** * *** ** * * ** ** * ***
* * ***** * * ** **** **** * *** * * * ****** ** ** ** *
** *** ** * ** * * ** *** ****** * ** * * * ** * * * ** *
* * ** * ** * ** * * ****** * * ** ***** **** ** *
********** ** ** * * * ** **** * ** ** ****
    }
* ** * * * ******** *** * * * ** **
** * * * ** ** ****** ** ** * **** ** * most occurring item:%d",max,min,most);
    return 0;
}
answered by (-498 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 arr[10],i,greatest=0,smallest,j,counter=0,place=0,num=1;
    for(i=0;i<10;i++){
*** *** *** ** ** ** ** * ** * ** * * ** * *** * ** ***
    }
    smallest=arr[0];
    for(i=0;i<10;i++){
* * *** * * ** *** * * ** ***** * * * **** * *** ** *
        {
***** *** *** * ** * * * **** **** *** ** ***** ** * * *** ** ** * **
* * ** * **** ** ** ** * *** * * * * * *
* * * *** * ** ** *** * * * ** * * **** *
***** * * ** * * * ** * * ***** * ** * ** *
*** * * ** * * ** * * * * **** * ** **** * **
**** *** *** ** * * ** **** * ******** * * **** ****
* * ***** ** * ** * *** ** * ** * * * ** * * *
* * * * * * ***** * * * *** ********** *
* * ** * *** * *** ** ** *** * * **** * * ** * * * ** * *** *** * ****
*** ** * * * *** ** *** **** **** * * ** * ** * ** ** ***
**** * ****** ** * * * *** * ** *** ** * ** *** * ***** ** * *** * * * * ** ** * ** * **
* *** ** * ** ** ** ** ** * *** ** *** * * * * * * * * * **** *
* * **** * ******* * * *** * * * * * *** ** **
* * ** * ** *** * ** ** ** *** * * * *** ** * * * * *** * * * ******* * *
* * ** *** * *** * * * *** ** ** ** * ** ** *** * *
** *** *** *** * * ***** **** ****** *** * * ** * * **** * * * * **** * * ** * * ** *
* * ** *** *** * *** ****** ** * ** ** **** ** *** * ** * *** * * ** * *
* *** * * ** * *** *** * *** ** ** * * *** ******** **
* * * ** * * * ** * * * ** ** * * * * * *** * * * *** * * **** *
    }
** ** ** * ***** * * ** * * * * *** * * * * ****
* *** *** * * * * **** * * * **** * * ******* *
    printf("The most occurring item:%d",arr[place]);
    return 0;
}
answered by (-254 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>
#include <stdlib.h>
#include <string.h>

int main()
{
    int a[10],i;

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

    int greatest=a[0];

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

    int smallest=a[0];

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

    int occur[10]={},most=occur[0];

** * * *** ** * *
    {
* * * * * * *** ** ** * * * * * *** ** * k;
* * ** * *** *** ** ** ** ** ** * **** ******
* ** * * **** ** ** * * ** * ** * *** * *** *** ** ** ** * ****
*** * * ** *** * ** *** * * ** * * * * * ******** ** * * ** ** * *
    }

    int frequent;

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

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


* * * * *** ** ****** * * ** * ** *** ** ** * * ** *** * ****
* ** ** * * *** ***** * * *** *** * * ** **** *
** * * ** * * ** * ** * ** ** most occurring item:%d",frequent);

** **** * * **** ******* * * 0;

}
answered by (-16 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>
#include <stdlib.h>
#include <string.h>

int cmp(const void *a, const void *b)
{
* *** * ** * * ** * * * *(int*)a-*(int*)b;
}
int main()
{
* * * **** * * ****** i,j,temp=0,count=0,arr[10],most;
* ** * * * ** * *** *** (i=0;i<10;i++)
*** * ** * **** * ** ** *
* * * *** ** ** * ** * * *** * * *** *** ** *** * *** ** *** *
*** *** *** *** * ** * *
* * * ** * * *** ** ******* * *
** ***** ******* * * * (i=0;i<10;i++)
**** * ** * ** ** **
** *** ** *** ** ** *** * ** ** ** ** (j=0;j<10;j++)
    {
****** * * * * *** *** * *** ** *** * * * * (arr[i]==arr[j])
    {
* **** ** **** *** * * * *** ** ** ** * * ** ** **** ** * *** * * *** * * * *** *****
** *** * *** ** ** * * * * * * *** ** ** * ***
** * * ** * ** * * ** ** * *** **** (temp>count)
* * **** ** * * ***** * ** ******* * * **
* * * ** ** ** *** **** * ** ***** ** **** * ** * ** *** * ** * * *** * * ** * **** *
*** *** ****** * **** *** ** * *** **** * * * ** ** *** * * ** * ** ** **** * **
*** * * * ** ** * * ** ** * ******* ** * * * ********
* * *** ** ** ** ** *** * * * * * ** *
* * *** * * ** * * **** **** ** ** **** **** * * *
* * * * * * **** *****
*** * **** ** ** ***** *** ** ** * * **** *
* * * * ** *** ** * * *** ** * * * * ** *** ** ***
**** * ** * * * ***** * * * *** most occurring item:%d",most);
** ** * * * ** * ** * * 0;
}
answered
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>
#include <string.h>

int main()
{
* **** * *** ** * * * * * * a[10],i,j,Greatest = 0,Smallest = 1000,x = 0,y = 0,z;
**** ** * * * ** *** *** = 0 ; i < 10 ; i++)
**** * * ****** ******* *** * ** ***** *** * * * * * ***
** * * *** **** * * ** = 0 ; i < 10 ; i++)
    {
** ** ***** ** ****** ****** ** ***** * * * * * > Greatest)
* * ** * **** * * * ** ** *** * ****** * * * ** *** **** ** ** * ** ** * = a[i];
* * * * * * * **** ** ** * ***** * * * * * * ** < Smallest)
**** ** ****** ** * ** * ** ** * * **** ** * ** * * ** * ** = a[i];
******** * * * * **
***** ****** * *** ** ** **** ** = 0 ; i < 10 ; i++)
    {
*** *** * * * * * *** * ** *** * ** * * ** ** ** = 0 ; j < 10 ; j++)
* * ***** **** * * ***** * ** * * * * ** * ** * * ****
** * * * * ***** ** **** ** * ** * * * ** ** * ** ** *** * ** *** == a[j])
**** **** * * * * * * * ** **** *** * * ****** * * *** * * * * * ** *** * *** * * * * * *
* *** * **** * * ** ** * * * **** * * * **
** * * * *** * ** **** *** ** * **** *** * > y)
** * * * ** * ** * ** * * * ** *** ***
* ** *** * ** *** * * * * ** *** **** **** ** *** * * * ***** * = x;
* ****** * *** * ** *** ** * * * *** *** * * *** * = a[i];
* * * ****** * ** * * * * **** ** ** * *
* *** * ** * ** * * ** ** * ** ** = 0;
* ** * **** * * * *

** *** * * * * ** * * * ****** * ** ** ** **
*** ***** ** **** ** ***** *** ** *** * * ******* * *
* * ** * ** * *** * * * * most occurring item:%d",z);
*** * **** * ** ***** 0;
}
answered by (-255 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>
#include <stdlib.h>
#include <string.h>

int cmp(const void *a, const void *b)
{
* ** ** * *** * *** *(int*)a-*(int*)b;
}
int main()
{
***** ** * * * *** * * i,j,temp=0,count=0,arr[10],most;
** ** ** * ** (i=0;i<10;i++)
    {
* ** * * * * * ** *** * **** * *** * *** * *** * * *** *** * *
    }
* ** ** ** * * ** **** ** * * * ** * *
** ** **** * * * * ** (i=0;i<10;i++)
    {
** * ** * *** * * * ** ** *** * * * ** (j=0;j<10;j++)
**** * * * * * * * * ** ** * * * *
*** ** ** ** * ***** *** ***** * *** * ******* * ***** * **** (arr[i]==arr[j])
* ******* ** ** ****** * * * ** ** * * * ** * * * * * *** **
******* * * * ** * *** ** ** ** * * * ** ** ** * ** ** ** ** *** * * ** * ** * * * *
** *** * * ** ** * *** **** ** ** * * ** * * ** *** ** * * **
******* * * ** ** * * ** * ** * ** *** ** ***** * * ** ** *** (temp>count)
*** *** *** * **** * * * *** ** **** *** * * *** * * *** **
* * * * ** **** ** *** *** * ** * *** * ** *** ** * * * ***** * * **** ** ***** ** * * ** *** * **
* ** * * * ****** * **** ** *** *** * *** ******** *** * *** * ***** ** *** *
* * * * * * *** * * ***** * * * * * * * **** * ** * ** *
** * * ** ** ** **** ** ** **** ** ** * * *** ** **
* * * **** * *** * *** * * * *** *** *
    }
*** ** *** **** * ** * ****** * * * * *** *** ** ***
* ***** *** * ***** * ** ** * ** * * **** *
* **** * **** *** * *** ** ** ** most occurring item:%d",most);
*** *** * * **** **** *** * 0;
}
answered by (-140 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>
#include <stdlib.h>
#include <string.h>

int cmp(const void *x, const void *y);
int main()
{
** * * ** * * * ** ** * * i,j,temp=0,cnt=0,a[10],max;
***** ** * *** ** * (i=0;i<10;i++)
    {
* * * * * * * * *** * ** * * * ** * ** * ** ** ******* *** * *** **
    }
** * ** ** ** ** *** * ** * * **** * ** *
***** *** * * * *** (i=0;i<10;i++)
    {
* * ** ****** ** * * * **** ** * ** (j=0;j<10;j++)
* * ** ******* * *** * * ** * ** * * * **
*** * ** ** * *** * * ** *** * ******** * *** ** * ** (a[i]==a[j])
** * ** *** * ** *** *** * * ****** *** * * * * ** ** * ****
** * ** **** * *** * ** ** * * * * ** **** ****** *** ** * ******* *** * * ** ** * * ** **
*** * * ********* ** * * *** * * ** *** ** **** ***
** * *** * ** * * * *** *** ** * * * * ** * * * ** **** *** ** (temp>cnt)
* * *** ***** ****** *** ** ** ** * * * * ** ** * * * * ** * *
** *************** ** * ***** * * * ***** * * *** * **** *** * * ** ** ** * ** *** *** ** **** **** ** * **
* * ***** * * * * **** ** * *** * * * ** *** **** * * **** * ** *** * * ** * * ** *
* * * * *** **** * *** * * ***** **** ** * ***** * **** *
*** **** ** *** *** * **** ** * ** * ** ****
* *** * ** ** * * * ** * ** * * * * *** ***
* ****** * ** * *
*** * * *** *** * * * * ** ** * * * ***** ***
** * *** * * * ** * * * ** ** **** *** *
* * ** ** ** * * * * * most occurring item:%d",max);
** * * * * ***** *** ** 0;
}

int cmp(const void *a, const void *b)
{
* * * * ** * ** ** *(int*)a-*(int*)b;
}
answered by (323 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:12:5: error: expected identifier or '(' before '}' token
     }
     ^
prog.c:18:23: error: 'arr' undeclared (first use in this function)
             if (a[i]==arr[j])
                       ^~~
prog.c:18:23: note: each undeclared identifier is reported only once for each function it appears in
prog.c:39:1: error: expected declaration or statement at end of input
 }
 ^
0 0
prog.c: In function 'main':
prog.c:12:5: error: expected identifier or '(' before '}' token
     }
     ^
prog.c:39:1: error: expected declaration or statement at end of input
 }
 ^
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>
#include <string.h>

int main()
{
* * **** * ** * * * * a[10];

** ** * * ***** * * * i = 0;

*** ** ** *** * * *** = 0; i < 10; i++)
    {
** *** * **** **** ** ** * ****** *** ** * * *** * * * *** &a[i]);
    }

* * ** ** ** ******* * smallest = 1000;

* ** ** * * greatest = 0;

* * * * ** * ** * * * = 0; i < 10; i++)
    {
*** *** ** * ** ***** * * *** *** ** * ******* > greatest)
* **** * * * *** ** ** * ** *** **
**** * * * * ******* * **** ***** * ** ** ** * ** * ** **** * * = a[i];
* * ** * * * * * * ** * ***** ***** *** *
*** ** ** ** ** * * * ****** **** * ***** * < smallest)
* * ** * * * **** * * * * * **** * * * ****
***** * * * * *** ** * * * ** * * * ** * * * ***** * * ** * **** * * = a[i];
** ** ** ******* * ** * *** *** ** *
* *** *** * * ** ** ****

** * *** * *** ** * ** * ** * * * * * *** * * ** greatest, smallest);

* ****** ** * ** ***** * count = 0;

** ** **** * * * * most_occuring = 0;

* * * ** ** * ** cnt_record = 0;

* * ** * *** *** * ** j = 0;

** * * ** * * * *** = 0; i < 10; i++)
    {
** ** ***** * ** ** * * * **** **** *** * ** = 0; j < 10; j++)
*** ** * * * * ** * * * ** ** * ***** ***** * **
****** ** * ** * * ** *** ** ** * * * * ** * **** * ****** ** * ** * * == a[j])
**** * ** * **** * *** * * *** * ** ***** * * * ***** ***
** *** **** *** * ** * ******** * ***** * * ** **** * **** * ** * ** ** * * * **
***** * * ***** ** * * * * * ** * *** *** **** * * ** ** ***
** * ** ** ** * ** * *** * ** ** * *

**** * ** * * * * * ** * ** ***** *** ** *** * > cnt_record)
* ** ********** * *** * * ** * * * ** * ** **
**** *** * * * ** *** ** ** *** ** * * ** * * * ***** * = a[i];

** * * * ** ***** * *** ** * ** ** ** * **** ******** * ** * * * = count;
* ******* ***** * ** * ** * ** * * * **

* * * ** **** * * *** **** *** *** *** * * * * = 0;
** * * * * ******

*** * * ** *** *** * ****** ** ** * * ** most occurring item:%d", most_occuring);
*** ** * * ** * ** 0;
}
answered by (-285 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>
#include <stdlib.h>
#include <string.h>

int cmp(const void *a, const void *b)
{
** ** * * ** * * * * * * *(int*)a-*(int*)b;
}
int main()
{
*** ** ** * ** **** * ** * i,j,temp=0,count=0,arr[10],most;
***** * * **** * ** ** (i=0;i<10;i++)
    {
* ** * * * * ***** **** * **** * ** * * * ***** **** ** *** *** * **
    }
** * ** ** * * ** *** * * * ** * * *
* ** ** ***** * * * *** * ** * (i=0;i<10;i++)
    {
* *** ***** * * *** ** *** *** ** * *** ** * (j=0;j<10;j++)
* *** ** * **** * *** * * * * * **** *
** *** *** * *** ** *** ******** * * ** ***** ** ** *** * * * * *** * (arr[i]==arr[j])
* * ** * * ***** * ** ** * * ** ** *** * **** ** ** * ** * * * *
** ** *** ** ** * *** * * **** ** ** * ** **** * ** ** **** * *** * *** * ***** ** *
* ***** * * **** **** * *** ** * * * * **** * * ******
* **** *** ** ** *** ** * * * * ** * * *** * * **** ** * ** (temp>count)
* ** * * *** ** ** * * ** * ** * ** *** * ** ** ******** *** * **
***** * ** * ** * ****** ** * *** ** **** *** ** * **** * **** * * * * * * ** * * * * ****
*** ** * *** *** * ** ** * ** ** * ** * *** ** ** *** ** ** * ** * ** * * ** ***** * **** *
*** ***** ** *** *** * * * * * ****** * *** ** * *** * * * * * * * **
** ***** *** * * *** * ** * **** *** ** *
* * ** ** *** * * * * ** *** * ** ** *
    }
* * * ** ** ** * ** * ** * * * * * * ****
**** ** * **** ** *** *** *** *** **
*** **** ** * * ***** **** ** ** * most occurring item:%d",most);
** * *** * * ** * *** 0;
}
answered by (-249 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
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.59.118
©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
| 1.8k 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
| 2.1k 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
| 2.2k 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
| 1.5k 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
| 701 views
12,783 questions
183,443 answers
172,219 comments
4,824 users