main
lensfrex 3 years ago
parent 2e90624a1e
commit c81f1fa9cb
Signed by: lensfrex
GPG Key ID: 0F69A0A2FBEE98A0
  1. 22
      pure-c-test/20220428/test-4-3.c
  2. 0
      pure-c-test/20220428/test-4-9.c

@ -0,0 +1,22 @@
#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);
}
Loading…
Cancel
Save