C语言猜字谜游戏

来源:互联网 发布:川普 希拉里 知乎 编辑:程序博客网 时间:2024/04/27 21:58

采用课本所提有序四元组来解决

在编辑代码过程中发现一个有趣的问题

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 :1234please input the line of the table :1234please input the line of the table :1234please input the line of the table :1234一开始的不在数组定义中的【2,4】49之后的不在数组定义中的【2,4】输出结果please input the line of the table :1234please input the line of the table :1234please input the line of the table :1234please input the line of the table :1234一开始的不在数组定义中的【2,4】49之后的不在数组定义中的【2,4】输出结果1 2 3 41 2 3 41 2 3 4 2 3 41 2 31 2 3 42 3 43 4 请按任意键继续. . .1 2 3 41 2 3 41 2 3 4  2 3 41 2 31 2 3 42 3 43 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)

为什么只有他关联?


因为地址

太难

所以放弃了




原创粉丝点击