C語言猜字謎遊戲

採用課本所提有序四元組來解決

在編輯代碼過程中發現一個有趣的問題

void input_table(char table[4][4])
{
	char tempchar[5];
  for(int i=0;i<4;i++)
	{
    printf("please input the line of the table :\n");
    scanf("%s",tempchar);
	strcpy(table[i],tempchar);
	}
}//輸入謎面
void output_table(char table[4][4])
{
  for(int i=0;i<4;i++)
  {
	  for(int j=0;j<4;j++)
	  {
		  printf("%c ",table[i][j]);
	  }
	  printf("\n");
  }
  //輸出謎面
}

char Skewtrix(char table[4][4],char table1[4][4])
{
	for(int i = 0;i < 4;i++)
	  {
		   int temp,temp1;
			temp=i-(4-num);
			temp1=(4-num)-i;
			if(temp<0){temp=0;}
			if(temp1<0){temp1=0;}
        for(int j = 0;j < 4;j++)
		{
			table1[i][j] = table[temp1+j][j+temp];
        }
    }
	return table1[4][4];
}//斜置

void main()
{
    char table1[4][4];
//inputdty(dictionary);
input_table(table);
printf("\n%c",table[2][4]);
table[2][4]=3;//令這個數字等於幾,輸出結果會在第四行多幾個空格
Skewtrix(table,table1);
output_table(table);
output_table(table1);
system("pause");
}


please input the line of the table :
1234
please input the line of the table :
1234
please input the line of the table :
1234
please input the line of the table :
1234
一開始的不在數組定義中的【2,4】
49
之後的不在數組定義中的【2,4】


輸出結果please input the line of the table :
1234
please input the line of the table :
1234
please input the line of the table :
1234
please input the line of the table :
1234
一開始的不在數組定義中的【2,4】
49
之後的不在數組定義中的【2,4】

輸出結果
1 2 3 4
1 2 3 4
1 2 3 4
 2 3 4
1 2 3
1 2 3 4
2 3 4
3 4 
請按任意鍵繼續. . .
1 2 3 4
1 2 3 4
1 2 3 4
  2 3 4
1 2 3
1 2 3 4
2 3 4
3 4
請按任意鍵繼續. . .

這是等於0 的結果

please input the line of the table :
1234
please input the line of the table :
1234
please input the line of the table :
1234
please input the line of the table :
1234
一開始的不在數組定義中的【2,4】
49
之後的不在數組定義中的【2,4】

輸出結果
1 2 3 4
1 2 3 4
1 2 3 4
2 3 4
1 2 3
1 2 3 4
2 3 4
3 4
請按任意鍵繼續. . .

這是等於1的結果


please input the line of the table :
1234
please input the line of the table :
1234
please input the line of the table :
1234
please input the line of the table :
1234
一開始的不在數組定義中的【2,4】
49
之後的不在數組定義中的【2,4】


輸出結果
1 2 3 4
1 2 3 4
1 2 3 4
         2 3 4
1 2 3
1 2 3 4
2 3 4
3 4
請按任意鍵繼續. . .

這個是等於9的結果


please input the line of the table :
1234
please input the line of the table :
1234
please input the line of the table :
1234
please input the line of the table :
1234
一開始的不在數組定義中的【2,4】
49
之後的不在數組定義中的【2,4】
1
輸出結果
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3
1 2 3 4
2 3 4
3 4 1
請按任意鍵繼續. . .

這是不給賦值的結果


初步結論table【2】【4】會影響【.3】【3】

其int值爲49,爲1的ascll碼錶值,即(2,4)關聯(3,3)

爲什麼只有他關聯?


因爲地址

太難

所以放棄了




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章