0_0_17982084_28785.cpp:2:3: error: expected unqualified-id before 'if'
if(a[i]==x||(abs(k-i)==abs(x-a[i]))) { return 0; } } return 1;}void dfs(int k,int end)//k表示行数 // 这里的dfs为到一步后 还有n步。{ int i; if(k>end) { sum++; return; } for(i=1;i<=end;i++) { if(visit(k,i)==1) { a[k]=i; dfs(k+1,end); } }}int main(){ long long sume[110],i,n; for(i=1;i<=10;i++) { sum=0; memset(a,0,sizeof(a)); if(n==0) break; dfs(1,i); sume[i]=sum; } while(~scanf("%I64d",&n)) { if(n==0) break; printf("%I64d\n",sume[n]); } return 0;}
^
0_0_17982084_28785.cpp:2:59: error: expected declaration before '}' token
if(a[i]==x||(abs(k-i)==abs(x-a[i]))) { return 0; } } return 1;}void dfs(int k,int end)//k表示行数 // 这里的dfs为到一步后 还有n步。{ int i; if(k>end) { sum++; return; } for(i=1;i<=end;i++) { if(visit(k,i)==1) { a[k]=i; dfs(k+1,end); } }}int main(){ long long sume[110],i,n; for(i=1;i<=10;i++) { sum=0; memset(a,0,sizeof(a)); if(n==0) break; dfs(1,i); sume[i]=sum; } while(~scanf("%I64d",&n)) { if(n==0) break; printf("%I64d\n",sume[n]); } return 0;}
^
|