提交时间:2023-12-29 17:19:56
运行 ID: 35165
#include<bits/stdc++.h> using namespace std; int fy[6][6]={{0,0,0,0,0,0}, {0,0,0,1,1,0}, {0,1,1,0,0,1}, {0,0,1,1,0,0}, {0,0,0,0,1,0}, {0,0,1,0,0,1}}; int a[555]; bool c[555]; int sum=0; void che(int x) { if(x==1) { printf("A\n"); } else if(x==2) { printf("B\n"); } else if(x==3) { printf("C\n"); } else if(x==4) { printf("D\n"); } else if(x==5) { printf("E\n"); } } void print() { printf("answer %d:\n",sum); printf("Student Zhang:"); che(a[1]); printf("Student Wang:"); che(a[2]); printf("Student Liu:"); che(a[3]); printf("Student Sun:"); che(a[4]); printf("Student Li:"); che(a[5]); } void fun(int k) { for(int i=1;i<=5;i++) { if(c[i]==false&&fy[k][i]==1) { a[k]=i; c[i]=true; if(k==5) { sum+=1; print(); } fun(k+1); c[i]=false; } } } int main() { fun(1); return 0; }