0
我想知道如果你能告訴我我做錯了什麼。這裏是我正在研究的戰列艦遊戲的一小部分,它應該顯示兩個清晰的數組,填充了「=」符號,但我所得到的只是一團糟。傳遞數組作爲參數C
#include <stdio.h>
int p_ship_count;
int e_ship_count;
#define EMPTY 0
#define BORDER 2
#define SHIP 1
#define HIT 4
#define MISS 3
#define SHOW 5
void print_boards(char *message,int e_board[][12],int p_board[][12])
{
int i;
int v,q;
printf("\t A B C D E F G H I J\n");
for(i=0,v=10,q=0;i<100;++i)
{
if(v==10)
{
if(q<9) printf("\n\t %i ", ++q);
else printf("\n\t%i ", ++q);
v=0;
}
++v;
if(e_board[v][q] == EMPTY) printf("= ");
if(e_board[v][q] == SHIP) printf("O ");
if(e_board[v][q] == BORDER) printf("+ ");
if(e_board[v][q] == MISS) printf("+ ");
if(e_board[v][q] == HIT) printf("@ ");
}
printf("\n\n\tenemy %i\n\t------------------------\n\tplayer %i\n\n\t A B C D E F G H I J\n",e_ship_count,p_ship_count);
for(i=0,v=10,q=0;i<100;++i)
{
if(v==10)
{
if(q<9) printf("\n\t %i ", ++q);
else printf("\n\t%i ", ++q);
v=0;
}
++v;
if(p_board[v][q] == EMPTY) printf("= ");
if(p_board[v][q] == SHIP) printf("O ");
if(p_board[v][q] == BORDER) printf("+ ");
if(p_board[v][q] == MISS) printf("+ ");
if(p_board[v][q] == HIT) printf("@ ");
if(p_board[v][q] == SHOW) printf("X ");
}
printf("\n\n\t");
for(i=0;message[i]!='\0';++i)
{
printf("%c",message[i]);
}
printf("\n\n");
}
int main()
{
int e_board[12][12];
int p_board[12][12];
print_boards("",e_board,p_board);
return 0;
}
刪除標籤'c#' – SeM
你爲什麼使用標籤C++?這是c代碼 –