Java Reference
In-Depth Information
——————-——————
| | | |
——————-——————
| | | |
——————-——————
| | | |
——————-——————
Enter a row (0, 1, or 2) for player X:
Enter a column (0, 1, or 2) for player X:
1
1
——————-——————
| | | |
——————-——————
| | X | |
——————-——————
| | | |
——————-——————
Enter a row (0, 1, or 2) for player O:
Enter a column (0, 1, or 2) for player O:
1
2
——————-——————
| | | |
——————-——————
| | X | O |
——————-——————
| | | |
——————-——————
Enter a row (0, 1, or 2) for player X:
. . .
——————-——————
| X | | |
——————-——————
| O | X | O |
——————-——————
| | | X |
——————-——————
X player won
*7.10
( Largest row and column ) Write a program that randomly fills in 0s and 1s into a
4-by-4 matrix, prints the matrix, and finds the first row and column with the most
1s. Here is a sample run of the program:
0011
0011
1101
1010
The largest row index: 2
The largest column index: 2
**7.11
( Game: nine heads and tails ) Nine coins are placed in a 3-by-3 matrix with some
face up and some face down. You can represent the state of the coins using a 3-by-
3 matrix with values 0 (heads) and 1 (tails). Here are some examples:
0 0 0 1 0 1 1 1 0 1 0 1 1 0 0
0 1 0 0 0 1 1 0 0 1 1 0 1 1 1
0 0 0 1 0 0 0 0 1 1 0 0 1 1 0
 
Search WWH ::




Custom Search