急求!!!!周四就交!请大侠们帮帮忙吧,小弟在此谢谢了!! 50
1.TheuserinputsintegerstocreatetwoBingocardsthatarestoredastwo5X5arrays.Eachcardisorg...
1. The user inputs integers to create two Bingo cards that are stored as two 5X5 arrays.
Each card is organized in the following manner. The first column consists of integers from 1 to 15, the second column consists of integers from 16 to 30, the third column consists of integers from 31 to 45, the fourth column consists of integers from 46 to 60, and the last column consists of integers from 61 to 75. Note that the numbers are not repeated.
2. The program randomly calls integers in the range 1-75. Note that the numbers should not be repeated.
3. As each number is called, the program should check to see if the called number is in Card1 or Card2 or both.
4. If it is found in either card, set that element to 0.
5. If any card has an all-0 row, or an all-0 column, or an all-0 diagonal, then it is the winner.
6. Print the winning card with the all-0 row, column or diagonal. Note that there could be a tie
For example, here are two cards:
Card1
2 29 37 54 62
7 26 40 49 65
14 23 42 58 69
12 19 43 57 68
8 24 36 50 64
Card2
8 16 39 56 69
13 29 37 60 66
5 25 45 53 62
7 19 31 48 71
11 21 33 50 70
Background: In order to do this assignment, you need a bit of background in 2-dimensional arrays. 2-d arrays are very similar to 1-d arrays except that they have two subscripts or indices, one representing the row number and the other representing the column number.
For example,
int[][] a = new int[5][5];
creates a 2-d array with 5 rows and 5 columns.
You can process the 2-d array in the same manner. Instead of one for loop, we use a nested for loop. For example,
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
System.out.print(a[i][j] + “\t”);
System.out.println();
} 展开
Each card is organized in the following manner. The first column consists of integers from 1 to 15, the second column consists of integers from 16 to 30, the third column consists of integers from 31 to 45, the fourth column consists of integers from 46 to 60, and the last column consists of integers from 61 to 75. Note that the numbers are not repeated.
2. The program randomly calls integers in the range 1-75. Note that the numbers should not be repeated.
3. As each number is called, the program should check to see if the called number is in Card1 or Card2 or both.
4. If it is found in either card, set that element to 0.
5. If any card has an all-0 row, or an all-0 column, or an all-0 diagonal, then it is the winner.
6. Print the winning card with the all-0 row, column or diagonal. Note that there could be a tie
For example, here are two cards:
Card1
2 29 37 54 62
7 26 40 49 65
14 23 42 58 69
12 19 43 57 68
8 24 36 50 64
Card2
8 16 39 56 69
13 29 37 60 66
5 25 45 53 62
7 19 31 48 71
11 21 33 50 70
Background: In order to do this assignment, you need a bit of background in 2-dimensional arrays. 2-d arrays are very similar to 1-d arrays except that they have two subscripts or indices, one representing the row number and the other representing the column number.
For example,
int[][] a = new int[5][5];
creates a 2-d array with 5 rows and 5 columns.
You can process the 2-d array in the same manner. Instead of one for loop, we use a nested for loop. For example,
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
System.out.print(a[i][j] + “\t”);
System.out.println();
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询