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!
#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 (-284 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
0 0
prog.c: In function 'main':
prog.c:10:20: error: subscripted value is neither array nor pointer nor vector
     {scanf("%d", &a[i])}
                    ^
prog.c:10:24: error: expected ';' before '}' token
     {scanf("%d", &a[i])}
                        ^
prog.c:15:13: error: subscripted value is neither array nor pointer nor vector
         if(a[i] > greatest)
             ^
prog.c:17:25: error: subscripted value is neither array nor pointer nor vector
             greatest = a[i];
                         ^
prog.c:19:13: error: subscripted value is neither array nor pointer nor vector
         if(a[i] < smallest)
             ^
prog.c:20:22: error: subscripted value is neither array nor pointer nor vector
         {smallest = a[i];}
                      ^
prog.c:32:17: error: subscripted value is neither array nor pointer nor vector
             if(a[i] == a[j])
                 ^
prog.c:32:25: error: subscripted value is neither array nor pointer nor vector
             if(a[i] == a[j])
                         ^
prog.c:37:30: error: subscripted value is neither array nor pointer nor vector
             most_occuring = a[i];
                              ^
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()
{
    int a[10];
    int i,j;
    int count=0;
    int occ=0;
    int most=0;
    int max=0;
    int min=999999;
    int g,s;




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

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

 for(i=0;i<10;i++)
* ** ** * *** * ***
* * ** * ***** ** * * * ** ** * * * *** * * * * *
* ***** **** *** ** * * ***** * ** **** * * **
** * *** *** * *** * * ** ** * ***** *** ** *** ** **** * ** ***** * * *** *
* * ******* * ** * *** * * * * *** ****** *** *** **
* ** * ***** * * ** ** *****



for(i=0;i<10;i++)
** * * * **** * * * * * **
** ***** * * * * ****** * ** * * ** * ***** * ***
** ******** * * ** * * ** ** * * * ** * ** * * * *
* ***** *** ** * * ** * * * * * * ****** ** * ***** * * ** * * * **
**** ** ** ** * * ** * * * ******* * ** ** *** * * * ** * * * * * ****** ** *
* * ** * ******* *** * *** *** ** ***** * * ***** * ** ** **** * ** *** **** *** * * * ** *****
*** ***** * * * * * ** * * *** * * *** ** *** * *** **** *** ** * * ** * ** *** * **

* *** ** * * * * * * ** * * ** *** * **** * * *
**** **** ** * ** * * * ****** *** ** ** ** * * * (count>occ)
**** ** ** **** * * **** *** ** ** * **** * **** *
* * ** *** * * ** *** * ** * * **** *** *** * ** * * **** **** * * ** * * **
** * * *** * *** ** * *** ** *** *** * ** * ** *** * ** * *** *
** * * ****** * * ******* * ** ** ** **** **** *** ***
**** ****** *** * * **** * ** ** * * *** *** *

* ** ** ** *** ***** ** **** * ****** * ** * **** (count=count)
* ** * *** * ******* * * ** ****** * *
* * ** *** ***** * ** * ***** * * * ***** * * * ****** * *** * **
** ** * *** * * ** ****** * ** **** * * * * * *
     }

** * * * ** ** ** ****** * * * ***** ** ** ** ** ** most occurring item:%d",max,min,most);



    return 0;
}
answered by (-193 points)
edited by
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{

* * * ** * * a[10],Greatest=0, Smallest=999, i, y=0, k=0, j, x=0;

* * ********* * **** ** * i<10; i++)
* * * ** * ** * **** ** * * *** * * ** * ** * ** ***

** * *** ** * ** ***** i<10; i++)
    {
* ** ** * * * * * * *** * * * * * * ** * *
* *** ***** * * *** ** * * **** * * * ** * * * * * * ***
* * * * *** * ***** * * ** * * ** * * ** (a[i]<Smallest)
*** * *** * ** ** **** ** * ** *** ** * *** *** ******** * ** ** * ** **
    }

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

** ** ** * * ** ** ** * *** * i<10; i++)
    {
* * **** * **** * ** *** * *** * * ** * ** *** j<10; j++)
*** * **** **** * * *** * * **** ** **
* * *** * * * ***** *** * *** ** * ** * * * * ****** * * *** * *** **
* *** ** * ***** ** ** * ** * * ** * * * * * * * * ***** * ** * ** * * * * * ****** * ** ****** *
** * * * * *** **** ** ** ********* ** ** *** **** *
****** * ** *** *** * * ** ** * * * ** * *
** **** * ** * * * ** * *** * * * * ***
** ** * ******** ** * **** * * * * * ** *** ** *****
* ******* * * ** * * * * ** * ** ** ** **** * ****** * *** *
****** * * * ***** * * * * ** **
** * ** *** ** * * *** * * * ** ** ** ** *
    }

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

* ***** ** * * * * * ** 0;
}
answered by (-127 points)
0 0
prog.c: In function 'main':
prog.c:6:37: warning: overflow in implicit constant conversion [-Woverflow]
     char a[10],Greatest=0, Smallest=9999, i, y=0, k=0, j, x=0;
                                     ^~~~
prog.c:9:17: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'char *' [-Wformat=]
         scanf("%d",&a[i]);
                 ^
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<limits.h>

int main(){
    int num[10];
* * * * * * ** *** * i=0;i<10;i++){
* * * * **** *** ** * * ** ** **** ******** ** * * * * * *
    }

*** *** ** * * ** G=INT_MIN,S=INT_MAX;
* ** ** *** * *** * * * i=0;i<10;i++){
** * * *** ** ** * * ****** ** ** ** *** ** * * * ** G=num[i];
* ** ** ** ** *** * **** *** **** ** ** * **** ** * ** S=num[i];
    }

****** ** ** * ** ****** tc=0,c=1,n=num[0];
**** ** * * * * ** ***** * i=0;i<10;i++){

** * * * * ** * ** *** * ****** *** ****** j=0;j<10;j++){
** * * *** * * * * * * *** ** * * ** * * * *** ** *** * ** *** ** ** * **** * ***
** * ** ** * * ** * * * * ** ** ** ** * **** * **** * **** * * ************** **** * *
** *** ** * * **** * ** * ** ** ** * * * ** ** ** ** * *
* * *** *** **** *** ** * * *

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

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

* * * *** ** * * ** * * 0;
}
answered by (-116 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 <string.h>
#include <ctype.h>
int main()
{
*** *** ** ****** ** ** * a[10];
* * ****** * *** * * * ** * i;
*** * * *** **** ******* **
** ******* *** ** * ** * *** ** *** * * * ** * ** * * * ******

* **** ** ** ** * *** ** max;
* * ******* * **** * ***
* **** ** * * * ****** * ** *
    {
*** ******* * * ******** ** * **** ** **** * *
*** * ** * ** *** ** ** * ** * ** * * * ** * if(a[i]>max)
* ***** * * ** *** ** ** ** * * ** * * * * **** *** * ** * * ** *
    }
* *** **** ** * ****** * *** * * *** * **


** ** ** *** * *** min;
*** ** * ** * ** ** *** **
* * * **** * * ** * * ** * ** *
    {
* * ** * * ***** * * * **** ** * ** **** ** * ** ** * *
* * * **** * *** ** * ***** ** * ** ** * * if(a[i]<min)
** * *** ** * * *** * ** * ** ** * * ** ** * * * ***** * ** * ****
    }
* * ** * * ** * * *** ****** * * *** ** * * *


*** * ** *** ** *** * *** b[10]={0};
    int j;
* *** * * * * *** * * **** ** *
    {
** * ** * *** * * ** ** * *** * * * * **
* ** **** ** ******* * **** * * * * *** ** **
* * * *** * ** * *** ** ** *** *** * * * *** * * * * ** * *** ***
* ** ****** * *** ** ** ** ** * * * * * ** * ** * *** *** *** * * *** * * * * * *** ** *
*** * * * ***** * ** * * ** ** * * *
    }

* * ** *** ******** * * c=a[0];
* * * ** * * ** * **** maxx=b[0];
*** *** *** * **** *** * * * **
    {
*** ***** **** ******* * * ** * * * *** * * ** ***
* * * ** * ** ****** ** **** * * * ** if(b[i]>maxx)
* *** * *** * ***** *** ** ** * **
* ** * ** * * **** * ********* * * **** **** * ** * **
*** * * * ** *** * * *** *** * *** ** ** * * *** ****
* * * ** *** * ** * ** * ** *** * * * **** * **

    }
* ** *** * * * * *** * **** most occurring item:%d",c);

** * ** * * * * * ** * * 0;
}
answered by (-196 points)
edited by
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct 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: 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!
#include<stdio.h>
int main()
{
    int arr[10],i,j,place,num=1,counter=0,smallest=0,greatest=0;
    for(i=0;i<10;i++)
    {
** **** ** ** * *** * ** ** *** * * * * ** * ** ** ***
    }
    smallest=arr[0];
* *** **** *********** * ** *** *
    {
** ****** * * * * **** ** * ** * * * *** * *** * **** * **
* ***** * ** * ** ** ** * *** * * *
*** * ** *** ***** * * ***** *** * * * * ** ** ** *** * ** * * * ** **
******* * ** * * * ** * * *
* **** * * * * ** *** **** ** * * * * * ** * ** * *** * ** *
***** ** ***** ***** * * ** ** ** * ** *
* ** * * ******** ** * * ** ** ** * * ** *** *** ** * * * * * *****
**** **** * **** ***** * ** ** * * * * * *
* * * ** * * * ***** **** * * * * * ** *** ** *
* * **** * * **** ***** **** ******** * ** ***
* ** ** * ***** ** * *** ******* * ***** ******** ** *** ** ***** *
*** ** ** ***** ** ** * * * * * **** * * **** ** ** * ***** ** ** *
* * * ** * ******* ** * * * * * *** ** * * ** * * ** * ****** * *** * *** ** **** *
* ** * * * ** * ****** * * *** ***** ** ** ** ** * *
*** * *** * * ** * ****** * * * * * * **
* *** * ******* ** *** * * * * ** ** ** ***** ***
* * * **** ****** * ** *** * * ** * **** * *** * * **
** * *** * ** ** * *** ** * *** * ******* * ** ** ****** ** **
* * *** *** * * * *** ****** ** *** * *** *** * ** * *** * * ** *** * **
* **** **** * *** *** * ** *****
* * * ** * * ** ** *** * *** * * ** *
    }
* *** ** * * * ***** * * * * * * * ** * * ** *** ** * * * **
* * * ** * * * **** ** * * * ** * * * * * * ****
    printf("The most occurring item:%d",arr[place]);

    return 0;
}
answered by (-323 points)
edited by
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct 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!
#include * * **** *
** ** * * * *** * *

int main()
{
* * *** ***** * * **** ** * ****
*** * *** *** * * **** * * 0;
}
answered by (-108 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.179.128
©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