From 75ce9f4b1d9f06462981edfbaac395d46a0918dc Mon Sep 17 00:00:00 2001 From: juan Date: Tue, 2 Nov 2021 11:03:48 +0800 Subject: [PATCH] add alternative answer for 1-soldiers --- pset6/1-soldiers-table.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 pset6/1-soldiers-table.c diff --git a/pset6/1-soldiers-table.c b/pset6/1-soldiers-table.c new file mode 100644 index 0000000..1a47b56 --- /dev/null +++ b/pset6/1-soldiers-table.c @@ -0,0 +1,15 @@ +#include + +int main(void) { + int table[] = {461, 2771, 5081, 7391, 9701, 12011}; + int n; + scanf("%i", &n); + + for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++) { + if (table[i] >= n) { + printf("%i\n",table[i]); + break; + } + } + return 0; +}