Day 2: Slightly simplify C solutions
Not sure why I did it that way. Maybe because I was originally going to use strtol or something?
This commit is contained in:
parent
03f4a91463
commit
d6bf929fc8
2 changed files with 4 additions and 14 deletions
|
@ -1,18 +1,13 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
int main(void) {
|
||||
FILE *fp = fopen("input.txt", "r");
|
||||
char buf[16] = {0}, *np;
|
||||
char buf[16] = {0};
|
||||
unsigned n, h = 0, v = 0;
|
||||
|
||||
while (fgets(buf, 16, fp) != NULL) {
|
||||
np = strchr(buf, ' ');
|
||||
assert(np != NULL);
|
||||
np++;
|
||||
|
||||
sscanf(np, "%u", &n);
|
||||
sscanf(buf, "%*s %u", &n);
|
||||
|
||||
switch (buf[0]) {
|
||||
case 'd':
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
int main(void) {
|
||||
FILE *fp = fopen("input.txt", "r");
|
||||
char buf[16] = {0}, *np;
|
||||
char buf[16] = {0};
|
||||
unsigned n, aim = 0, h = 0, v = 0;
|
||||
|
||||
while (fgets(buf, 16, fp) != NULL) {
|
||||
np = strchr(buf, ' ');
|
||||
assert(np != NULL);
|
||||
np++;
|
||||
|
||||
sscanf(np, "%u", &n);
|
||||
sscanf(buf, "%*s %u", &n);
|
||||
|
||||
switch (buf[0]) {
|
||||
case 'd':
|
||||
|
|
Loading…
Reference in a new issue