不太理解这个代码。。。
1 #include2 #include 3 int map[32][32],v[32]; 4 int n,max; 5 void dfs(int row,int sum) 6 { 7 8 int ans = sum; 9 v[row] = 1;10 for (int i = 1; i <= n; i ++)11 {12 if (v[i]==0)13 ans += map[row][i];14 else15 ans -= map[row][i];16 }17 if (ans > max)18 max = ans;19 for (int i = row+1; i <= n; i ++)20 {21 if (ans > sum)22 {23 dfs(i,ans);24 v[i] = 0;25 }26 }27 }28 int main()29 {30 scanf("%d",&n);31 max = 0;32 memset(v,0,sizeof(v));33 for (int i = 1; i <= n; i ++)34 {35 for (int j = 1; j <= n; j ++)36 {37 scanf("%d",&map[i][j]);38 }39 }40 dfs(1,0);41 printf("%d\n",max);42 return 0;43 44 }