From 4f96334063ecb30435f04b0c19e752498602d27f Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Fri, 27 Jun 2014 18:43:14 -0400 Subject: Cleanup, documentation --- gtnw.c | 23 +++++++++++++++++++---- main.cpp | 1 + 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/gtnw.c b/gtnw.c index e481ec3..1be73a0 100644 --- a/gtnw.c +++ b/gtnw.c @@ -13,9 +13,10 @@ static unsigned int max(long long a, long long b) { return a>b?a:b; } +/* simulate a missile launch */ static void fire_missile(struct location_t* city) { - int random=rand()%100; + int random=rand()%100; /* leave this at 100 for future adjustments */ int x=city->x, y=city->y; if(random>=90) /* crit */ { @@ -37,11 +38,13 @@ static void fire_missile(struct location_t* city) map[y][x]='x'; city->population=max((double)city->population*(double).8-100, 0); } - else + else /* miss */ { map[y][x]='O'; } } + +/* calculate populations of US+USSR by totaling the populations of each of their cities */ static void calc_pops(long long* us_pop, long long* ussr_pop) { *us_pop=0; @@ -55,6 +58,8 @@ static void calc_pops(long long* us_pop, long long* ussr_pop) *us_pop+=world[i].population; } } + +/* print the map and populations of the cities underneath */ static void print_map_with_pops(void) { for(int i=0;i #include + using namespace std; int main() { -- cgit v1.1