From c81f1fa9cbfd094c4eb605e0335411e06beb5367 Mon Sep 17 00:00:00 2001 From: lensferno Date: Thu, 28 Apr 2022 16:00:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pure-c-test/20220428/test-4-3.c | 22 ++++++++++++++++++++++ pure-c-test/20220428/test-4-9.c | 0 2 files changed, 22 insertions(+) create mode 100644 pure-c-test/20220428/test-4-3.c create mode 100644 pure-c-test/20220428/test-4-9.c diff --git a/pure-c-test/20220428/test-4-3.c b/pure-c-test/20220428/test-4-3.c new file mode 100644 index 0000000..c0385a9 --- /dev/null +++ b/pure-c-test/20220428/test-4-3.c @@ -0,0 +1,22 @@ +#include + +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); +} diff --git a/pure-c-test/20220428/test-4-9.c b/pure-c-test/20220428/test-4-9.c new file mode 100644 index 0000000..e69de29