借书方案知多少
小明有5本新书,要借给A,B,C这三位小朋友,若每次每人只能借一本,则可以有多少种不同的借法?
直接输代码
#include<iostream> using namespace std; int main() { int a = 0, b = 0, c = 0; for (int a = 1; a <=5 ; a++) { for (int b = 1; b <= 5; b++) { for (int c = 1; c <= 5; c++) { if (a != b && a != c && b != c) cout << a << " " << b << " " << c << " " << endl; } } } return 0; }