C语言 8 皇后 可以通过编译 无法达到预期目的

来源:百度知道 编辑:UC知道 时间:2024/06/05 10:58:47
#include <stdlib.h>
#include <stdio.h>
int success = 0;

int eightqueens (int qipans[][8], int x, int y, int times)
{
//备份
int tempx=x;
int tempy=y;
int qipan[8][8];
for (;tempx <= 7;tempx++)
{
for (;tempy <= 7;tempy++)
{
qipan[tempx][tempy] = qipans[tempx][tempy];
}
}

//置0
//斜

for(;tempx <= 7 && tempy <= 7;tempx++, tempy++)
{
qipan[tempx][tempy] = 0;
}
for(tempx = x,tempy = y;tempx >= 0 && tempy >= 0;tempx--,tempy--)
{
qipan[tempx][tempy] = 0;
}

//行
for (tempx = x; tempx <= 7; tempx++)
{
qipan[tempx][y] = 0;
}
for (tempx = x; tempx >= 0; tempx--)
{
qipan[tempx][y] = 0;
}
//列
for (tempy = y; tempy <= 7; tempy++)
{
qipan[x][tempy] = 0;
}
for (tempy = y; tempy >= 7; tempy--)
{
qipan[x][tempy] = 0;

你可以先看看这个,http://community.csdn.net/IndexPage/SmartQuestion.aspx或者这个: