add alternative answer for 1-soldiers

This commit is contained in:
juan 2021-11-02 11:03:48 +08:00
parent d4ef5f38b9
commit 75ce9f4b1d
No known key found for this signature in database
GPG key ID: 5C1E5093C74F1DC7

15
pset6/1-soldiers-table.c Normal file
View file

@ -0,0 +1,15 @@
#include <stdio.h>
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;
}