#include #define CITIES 9 #define JUDGES 5 typedef struct { char pszName[15]; unsigned long ulScore; unsigned long ulPop; } cityInfoType; typedef struct { unsigned long score[CITIES]; } judgeType; judgeType Judge[JUDGES] = { // judge 1 87, 80, 90, 95, 92, 87, 89, 94, 99, // judge 2 87, 80, 96, 100, 98, 89, 98, 94, 100, // judge 3 50, 45, 50, 65, 90, 80, 75, 98, 95, // judge 4 80, 75, 85, 95, 95, 85, 85, 100, 100, // judge 5 88, 94, 88, 92, 90, 95, 94, 92, 100 }; unsigned long ulFinalScore[CITIES]; cityInfoType City[CITIES] = { "11813", 0, 692759, // 11813 "ANKITVIL", 0, 8533988, // ANKITVIL "LILVIEW", 0, 94470, // LILVIEW "NEBULAR", 0, 4005974, // NEBULAR "NEWTON", 0, 8923375, // NEWTON "PETECITY", 0, 4117928, // PETECITY "TERRA4", 0, 213123, // TERRA4 "VESUVIUS", 0, 9042776, // VESUVIUS "ZIGZAG", 0, 9126881 }; // ZIGZAG void main( void ) { unsigned long c, j; unsigned long ulCities; unsigned long ulJudges; unsigned long ulTotal; ulCities = CITIES; ulJudges = JUDGES; for ( c = 0; c < ulCities; c++ ) { printf( "%10s ", City[c].pszName ); for ( j = 0; j < ulJudges; j++ ) { printf( "%4ld", Judge[j].score[c] ); } printf( "\n" ); } printf( "\n\n" ); // calc average score for each city for ( c = 0; c < ulCities; c++ ) { ulTotal = 0; for ( j = 0; j < ulJudges; j++ ) { ulTotal += Judge[j].score[c]; } City[c].ulScore = ulTotal / ulJudges; printf( "%ld %10s %4ld %10ld\n", c, City[c].pszName, City[c].ulScore, City[c].ulPop ); City[c].ulScore *= City[c].ulPop; } }