VC实现n皇后问题
int main(void) { int * x; int n,i,sum = 0; printf("请输入皇后的个数:\n"); scanf("%d",&n); x = (int *)malloc (n * sizeof(int)); if (x == NULL) { printf("\n"); exit(-1); } for (i = 0; i < n; i++) x[i] = 0; Backtrack(n, x, sum); printf("总共有 %d 种情况\n\n",sum); free(x); system("pause"); return 0; }
暂无评论