diff options
-rw-r--r-- | 19.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -16,6 +16,7 @@ enum MATERIAL { struct blueprint { + int id; int ore_ore; int clay_ore; int bsdn_ore; @@ -26,9 +27,10 @@ struct blueprint { void -blueprint_ctor(struct blueprint * b, int ore_ore, int clay_ore, +blueprint_ctor(struct blueprint * b, int id, int ore_ore, int clay_ore, int bsdn_ore, int bsdn_clay, int geod_ore, int geod_bsdn) { + b->id = id; b->ore_ore = ore_ore; b->clay_ore = clay_ore; b->bsdn_ore = bsdn_ore; @@ -182,7 +184,7 @@ main() while (fgets(buf, sizeof(buf), stdin)) { regmatch_t rematch[8]; - int bid, t; + int t; struct blueprint b; struct inventory i; @@ -191,8 +193,9 @@ main() continue; } - bid = atoi(buf + rematch[1].rm_so); - blueprint_ctor(&b, atoi(buf + rematch[2].rm_so), + blueprint_ctor(&b, + atoi(buf + rematch[1].rm_so), + atoi(buf + rematch[2].rm_so), atoi(buf + rematch[3].rm_so), atoi(buf + rematch[4].rm_so), atoi(buf + rematch[5].rm_so), @@ -206,14 +209,14 @@ main() inventory_tick(&i); fprintf(stderr, "Blueprint %d tick %d, ore: %ld/%ld, clay %ld/%ld, bsdn %ld/%ld, geod %ld/%ld\n", - bid, t + 1, + b.id, t + 1, i.ore.amount, i.ore.robots, i.clay.amount, i.clay.robots, i.bsdn.amount, i.bsdn.robots, i.bsdn.amount, i.bsdn.robots); } - printf("Blueprint %d geodes = %ld\n", bid, i.geod.amount); + printf("Blueprint %d geodes = %ld\n", b.id, i.geod.amount); } regfree(&reblueprint); |