注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。
#include <stdio.h> #include <string.h> #include <math.h> #include <algorithm> using namespace std; int a[10]={0,1,2,3,4,5,6,7,8,9}; int jdg(int x,int y){ if(abs(a[x]-a[y])==1) return 0; else return 1; } int check(){ return jdg(0,3)&&jdg(0,4)&&jdg(0,5)&&jdg(0,1) &&jdg(1,4)&&jdg(1,5)&&jdg(1,6)&&jdg(1,2) &&jdg(2,5)&&jdg(2,6) &&jdg(3,7)&&jdg(3,8)&&jdg(3,4) &&jdg(4,7)&&jdg(4,8)&&jdg(4,9)&&jdg(4,5) &&jdg(5,8)&&jdg(5,9)&&jdg(5,6) &&jdg(6,9)&&jdg(7,8)&&jdg(8,9); } int main() { int cnt=0; do { if(check()) cnt++; }while(next_permutation(a,a+10)); printf("%d\n",cnt); return 0; }
这里 感谢纪纲帮我调出的大错误。