1 喜歡 0 不喜歡
1.8k 瀏覽

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
[考試] 最新提問 分類:Final Exam |
ID: 42302 - 從幾時開始: 2018-01-17 14:00 - 到幾時結束: 無限制

標籤修改 用戶: | 1.8k 瀏覽

37 個回答

0 喜歡 0 不喜歡
內容已隱藏
** * ** * ****** ** *
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 ** *** *** * * ****










}
最新回答 用戶: (-336 分)
修改於 用戶:
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 喜歡 0 不喜歡
內容已隱藏
* * * *
** ****** ** * ****

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

** ***** 0;
}
80/100 最新回答 用戶: (-66 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#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;
}
最新回答 用戶: (-168 分)
修改於 用戶:
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 喜歡 0 不喜歡
內容已隱藏
#include * * *** * * **
int main ()
{
* * ** * * * * **** ** ** * * * * ** ***
****** ** * *** * ** * * * * * *****

******* ** * *
*** * * * * ***** *
* * * * * most occurring item:5");
** ** * * ** **** 0;
}
最新回答 用戶: (-32 分)
修改於 用戶:
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 喜歡 0 不喜歡
內容已隱藏
#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]);
}
最新回答 用戶: (-120 分)
修改於 用戶:
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 喜歡 0 不喜歡
內容已隱藏
#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);
}
最新回答 用戶: (-301 分)
修改於 用戶:
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 喜歡 0 不喜歡
內容已隱藏
#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;
}
最新回答 用戶: (-168 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#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 最新回答 用戶: (-32 分)
修改於 用戶:
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 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <stdlib.h>
int * ** * * * ** ** *** * ***** *

int main(){

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

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


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

    }


* * ** * * * *** * * * * *** ** *** ***
* ***** * * *** ** ********* ** * * * * * * ****
* * **** * * ** * ** *** * most occurring item:%d",popular2);
    return 0;
}
最新回答 用戶: (-286 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#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 最新回答 用戶: (-74 分)
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.127.162
©2016-2024

相關問題

2 喜歡 0 不喜歡
31 回答
[考試] 最新提問 1月 16, 2018 分類:Final Exam |
ID: 42301 - 從幾時開始: 2018-01-17 14:00 - 到幾時結束: 無限制
| 1.9k 瀏覽
1 喜歡 0 不喜歡
32 回答
[考試] 最新提問 1月 16, 2018 分類:Final Exam |
ID: 42300 - 從幾時開始: 2018-01-17 14:00 - 到幾時結束: 無限制
| 2.1k 瀏覽
1 喜歡 0 不喜歡
37 回答
[考試] 最新提問 1月 16, 2018 分類:Final Exam |
ID: 42299 - 從幾時開始: 2018-01-17 14:00 - 到幾時結束: 無限制
| 2.2k 瀏覽
2 喜歡 0 不喜歡
30 回答
[考試] 最新提問 1月 16, 2018 分類:Final Exam |
ID: 42298 - 從幾時開始: 2018-01-17 14:00 - 到幾時結束: 無限制
| 1.5k 瀏覽
0 喜歡 0 不喜歡
13 回答
[考試] 最新提問 1月 19, 2018 分類:Final Exam |
ID: 43463 - 從幾時開始: 2018-01-20 09:00 - 到幾時結束: 無限制
| 724 瀏覽
12,783 問題
183,443 回答
172,219 留言
4,824 用戶