You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
465 B
23 lines
465 B
2 years ago
|
#include <stdio.h>
|
||
|
|
||
|
int main() {
|
||
|
int candidates[5] = {0};
|
||
|
int vote = 0, invalidVoteCount = 0;
|
||
|
|
||
|
do {
|
||
|
scanf("%d", &vote);
|
||
|
if (vote >= 1 && vote <= 5) {
|
||
|
candidates[vote - 1]++;
|
||
|
} else if (vote != -1) {
|
||
|
invalidVoteCount++;
|
||
|
continue;
|
||
|
}
|
||
|
} while (vote != -1);
|
||
|
|
||
|
for (int i:candidates) {
|
||
|
printf("%d ",i);
|
||
|
}
|
||
|
|
||
|
printf("\n%d", invalidVoteCount);
|
||
|
}
|