借書方案知多少_numbers
來源:互聯網
上載者:User
//////////////////////////////////////////////////////////////////////////////// //第一次用窮舉法 // 05軟體 jacklam // 借書方案知多少 // EX8.cpp //////////////////////////////////////////////////////////////////////////////// #include "iostream.h" /////////////////////////////////////////////////////////////////////////////// /*factorial(int n) { int fact=1; while(n) { fact*=n; --n; } return fact; }*/ main() { int n,m,l=1; cout<<"please input the numbers of book can be borrowed:"; cin>>n; cout<<"please input the numbers of people want to borrow:"; cin>>m; //p=factorial(n)/factorial(n-m); //while(p--) //{ cout<<"there are different methods for XM to distribute books to "<<m<<" readers:"<<endl; for(int j=1;j<=n;++j) for(int k=1;k<=n;++k) for(int h=1;h<=n;++h) { if(j!=k&&j!=h&&k!=h) //如果有數字重複則不顯出 { cout<<l<<":"<<j<<" "<<k<<" "<<h<<" "; if(l%5==0) //每行輸出五個 cout<<endl; l++; } } //} return 1; }