Difference: HandsOnArray3 (1 vs. 2)

Revision 22017-10-02 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="Fall2017"
Changed:
<
<

Hands On Arrays 2

>
>

Tick Tack Toe

 

Goal

Changed:
<
<
Sorting Arrays and 2 dimensional arrays Arrays with Function calls

Step 1

  1. Create a function to enter a list of up to 25 quiz scores in array. A negative number indicates the end.
  2. Create a function to print the grade list back out.
  3. Write a main program to do the two functions above

Step 2

  1. Create a function to remove the low score of an array
  2. Enter the scores
  3. remove the two lowest grades.
  4. Print the reduced list back out.

Step 3

  1. Create a function "void lowest(int a[], int start, int size)" to scan from the ith position in an array to the end of the array, returning the index the lowest entry in the range.
  2. Create a function "void sort(int a[], int size)" to use the lowest function to scan through each element in the array, swapping the ith lowest value into the ith position.
  3. Use the routines from earlier to test the sort function

Step 4

>
>
Create a simple TTT game

Steps

 
  1. Consider the game Tic Tac Toe. How could a game be represented? Represent as a two dimensional array of char.
Changed:
<
<
  1. Manually create an Tic Tac Toe with the following:
    X O
    X O
    O X
>
>
  1. Manually create a Tic Tac Toe board on the screen with the following:
    X O
    X O
    O X
 
  1. Write a function "void displayBoard(char board[][3])" to display a Tic Tac Toe game state.
  2. Write a function "void nextMove(char player, char board[][3])" to ask a user for the row and column of a move. player will be 'X' or 'Y', and the program will check is the move is legal.
  3. Write a main program to allow two plays to play, starting with a blank board, and alternating between X and O turns.

Revision 12017-10-02 - JimSkon

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="Fall2017"

Hands On Arrays 2

Goal

Sorting Arrays and 2 dimensional arrays Arrays with Function calls

Step 1

  1. Create a function to enter a list of up to 25 quiz scores in array. A negative number indicates the end.
  2. Create a function to print the grade list back out.
  3. Write a main program to do the two functions above

Step 2

  1. Create a function to remove the low score of an array
  2. Enter the scores
  3. remove the two lowest grades.
  4. Print the reduced list back out.

Step 3

  1. Create a function "void lowest(int a[], int start, int size)" to scan from the ith position in an array to the end of the array, returning the index the lowest entry in the range.
  2. Create a function "void sort(int a[], int size)" to use the lowest function to scan through each element in the array, swapping the ith lowest value into the ith position.
  3. Use the routines from earlier to test the sort function

Step 4

  1. Consider the game Tic Tac Toe. How could a game be represented? Represent as a two dimensional array of char.
  2. Manually create an Tic Tac Toe with the following:
    X O
    X O
    O X
  3. Write a function "void displayBoard(char board[][3])" to display a Tic Tac Toe game state.
  4. Write a function "void nextMove(char player, char board[][3])" to ask a user for the row and column of a move. player will be 'X' or 'Y', and the program will check is the move is legal.
  5. Write a main program to allow two plays to play, starting with a blank board, and alternating between X and O turns.
  6. Write a routine "bool checkDone(char board[][3], char& winner)" to check for winner. Return true if there is a winner, and return winner ("X" or "O") in winner.
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback