问题描述:小明有5本新书,要借给A、B、C三位小朋友,若每人每次只能接1本,则可以有多少种不同的借法?
流程图:
伪代码:
for a<-1 to 5
for b<-1 to 5
for c<-1 to 5
if a=b=c
then continue
else output a,b,c
代码:
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
for(a=1;a<=5;a++)
{
for(b=1;b<=5;b++)
{
for(c=1;c<=5;c++)
{
if((a!=b)&&(b!=c)&&(a!=c))
cout<<"A:"<<a<<" B:"<<b<<" C:"<<c<<" ";
}
}
}
return 0;
}
标签:cout,int,代码,namespace,&&,打卡 From: https://www.cnblogs.com/chukjbgg333/p/17334544.html