// Author: // Date: // UNSW Freefall assignment. #include #include #include #define SIZE 15 #define EMPTY 0 #define STONE 1 // TODO: Add any extra #defines here. void printMap(int map[SIZE][SIZE], int playerX); // TODO: Add any extra function prototypes here. int main (void) { // This line creates our 2D array called "map" and sets all // of the blocks in the map to EMPTY. int map[SIZE][SIZE] = {EMPTY}; // This line creates out playerX variable. The player starts in the // middle of the map, at position 7. int playerX = SIZE / 2; printf("How many lines of stone? "); // TODO: Scan in the number of lines of blocks. printf("Enter lines of stone:\n"); // TODO: Scan in the lines of blocks. printMap(map, playerX); // TODO: Scan in commands until EOF. // After each command is processed, you should call printMap. return 0; } // Print out the contents of the map array. Then print out the player line // which will depends on the playerX variable. void printMap(int map[SIZE][SIZE], int playerX) { // Print values from the map array. int i = 0; while (i < SIZE) { int j = 0; while (j < SIZE) { printf("%d ", map[i][j]); j++; } printf("\n"); i++; } // Print the player line. i = 0; while (i < playerX) { printf(" "); i++; } printf("P\n"); }