单选题
下面的程序属于哪种算法( )。
int pos[8];void queen(int n) {\tfor (int i = 0; i < 8; i ) {\t\tpos[n] = i;\t\tbool attacked = false;\t\tfor (int j = 0; j < n; j )\t\t\tif (pos[n] == pos[j] || pos[n] n == pos[j] j || pos[n] - n == pos[j]- j) {\t\t\t\tattacked = true;\t\t\t\tbreak;\t\t\t}\t\tif (attacked)\t\t\tcontinue;\t\tif (n == 7) {\t\t\treturn;\t\t} else {\t\t\tqueen(n 1);\t\t}\t}}
A.
贪心算法
B.
动态规划
C.
深度优先搜索
D.
广度优先搜索
发表评论 取消回复