-
Notifications
You must be signed in to change notification settings - Fork 0
/
champion.c
37 lines (28 loc) · 1.01 KB
/
champion.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
int main() {
int number_of_teams=0, team, lowest;
scanf("%d%d", &number_of_teams, &team); int temp;
int * score_of_teams=malloc(110*sizeof(int));
int check;
for (int i = 0; i < number_of_teams; i++) {
scanf("%d", (score_of_teams+i));
}
for (int i = 0; i <number_of_teams; i++) {
lowest = 200;
for (int j = i; j < number_of_teams; j++) {
if (lowest > *(score_of_teams + j)) {
lowest = *(score_of_teams + j);
temp = j;
}
}
*(score_of_teams + temp) = *(score_of_teams + i); *(score_of_teams + i) = lowest;
}
// for (int i=0;i<number_of_teams;i++){
// printf("%d ",*(score_of_teams+i));
// }puts(" ");
temp =number_of_teams;
for (int i = 0; i < temp; i++) {
if (*(score_of_teams + i) < *(score_of_teams+ (temp-team))||(*(score_of_teams + i)<1))number_of_teams--;
}
printf("%d",number_of_teams);
}