메모리 게임을 코딩하라는 메시지가 표시됩니다. 몇 가지 구체적인 사항이 있습니다. 두 번째 프롬프트의 사용자가 해당하는 일치하는 지점을 추측하면 게시판은 계속 머물러 있어야합니다. 즉 사용자까지마스크 된 배열을 저장하는 방법
Your program:
* *
* *
Enter a pair of integers in the range [1, 2]
Player: 1 1
Your program:
A *
* *
(then it clears the screen and displays)
* *
* *
Enter another pair of integers in the range [1, 2]
Player: 2 1
Your program:
* *
C *
(then it clears screen and displays)
* *
* *
Enter a pair of integers in the range [1, 2]
Player: 1 2
Your program:
* C
* *
(then it clears screen and displays)
* *
* *
Enter another pair of integers in the range [1, 2]
Player: 2 1
Your program:
* *
C *
(then it clears the screen and displays)
* C
C *
Enter a pair of integers in the range [1, 2]
Player: 1 1
Your program:
A C
C *
(then it clears the screen and displays)
* C
C *
Enter another pair of integers in the range [1, 2]
Player: 1 1
Your program:
A C
C *
(then it clears the screen and displays)
* C
C *
Enter a pair of integers in the range [1, 2]
Player: 1 1
Your program:
A C
C *3
(then it clears the screen and displays)
* C
C *
Enter another pair of integers in the range [1, 2]
Player: 2 2
Your program:
A C
C A
CONGRATULATIONS. YOU SUCCEEDED
내가 4 × 4 필요 × 2 그리드 (올바른 일치하는 지점을 모두 추측하여)를 heres 예를 게임을 완료처럼, 나는 정확한 일치를 보여하지만 난 수없는 것 방법을 이해 새로운 보드를 저장하기 위해 사용자가 가장 최근의 보드를 볼 수 있으므로 내 머리를 감쌀 수 없습니다 ....
char board[4][4] = { {'A','B','A','D'},{'C','E','H','G'},{'B','D','G','C'},{'F','H','F','E'} };
int i, j, row, column, row2, column2;
char boardmatch[4][4];
int tempX,tempY;
for(tempX = 0; tempX < 4; tempX++){
for(tempY = 0; tempY < 4; tempY++){
boardmatch[tempX][tempY] = 0;
}
}
for (i=0; i < 4 ; i++){
for (j=0; j<4; j++){
printf("* ");
}
printf("\n");
}
do {
printf("\nEnter a pair of integers in the range [1, 4]: ");
scanf("%d %d", &row, &column);
row--;
column--;
printf("\n");
for (i=0; i < 4 ; i++){
for (j=0; j < 4 ; j++){
if (i == row && j == column){
printf("%c ", board[row][column]);
}else{
printf("* ");
}
}
printf("\n");
}
printf("\n");
system("pause");
system("cls");
for (i=0; i < 4 ; i++){
for (j=0; j<4; j++){
printf("* ");
}
printf("\n");
}
printf("\nEnter another pair of integers in the range [1, 4]: ");
scanf("%d %d", &row2, &column2);
row2--;
column2--;
printf("\n");
for (i=0; i < 4 ; i++){
for (j=0; j < 4 ; j++){
if (i == row2 && j == column2){
printf("%c ", board[row2][column2]);
}else{
printf("* ");
}
}
printf("\n");
}
system("pause");
system("cls");
if(board[row][column]==board[row2][column2]){
boardmatch[row][column] = 1;
boardmatch[row2][column2] = 1;
}
for (i=0; i < 4 ; i++){
for (j=0; j<4; j++){
if (boardmatch[i][j] == 1){
printf("%c ", board[row2][column2]);
}else{
printf("* ");
}
}
printf("\n");
}
printf("\n");
system("pause");
system("cls");
}while(1);
system("PAUSE");
return 0;
}
(다른 입력 바로 '후 첫 세트를 포함 : 그리고 나는 또한 개선 및/또는 교훈 제안
는 구조체를 사용하여 코드를 수정합니다. 마지막 세트가 잘못되어 있어야합니다 : printf ("% c", board [i] [j]); // row2, column2가 아닙니다 – Jiminion
"Enter a pair ..."후 보드 매치를 사용해야합니다. "다른 쌍을 입력 ....". 그게 당신의 주요 문제입니다. – Jiminion