-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproblem02.c
More file actions
34 lines (29 loc) · 713 Bytes
/
problem02.c
File metadata and controls
34 lines (29 loc) · 713 Bytes
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
#include <stdio.h>
#include <stdlib.h>
void checkShot(int n, int *shots, int *goodShot, int *badShot){
for (int i = 0; i < n; i++){
if (*(shots + i) >= 7)
(*goodShot)++;
else if (*(shots + i) < 7)
(*badShot)++;
}
return;
}
int main(){
int n, goodShot = 0, badShot = 0;
scanf("%d", &n);
int *shots = (int *)malloc(n * sizeof(int));
for (int i = 0; i < n; i++)
{
scanf("%d", &shots[i]);
if (shots[i] > 10 || shots[i] < 0)
{
printf("Invalid Score\n");
i--;
}
}
checkShot(n, shots, &goodShot, &badShot);
printf("%d %d", goodShot, badShot);
free(shots);
return 0;
}