int main()
{
char i,j,k//i是A的对手,j是B的对手,k是C的对手
for (i = 'x' i <= 'z' i++)
{
for (j = 'x' j <= 'z' j++)
{
if (i != j)
{
for (k = 'x' k <= 'z' k++)
{
if (i != k&&j != k)
{
if (i != 'x'&&k != 'x'&&k != 'z')
{
printf("A——%c\nB——%c\nC——%c\n", i, j, k)
}
}
}
}
}
}
return 0
}
A——z
B——x
C——y
Press any key to continue
int main(int argc, _TCHAR* argv[]){
char buff2[3]={'x','y','z'}
int i,j,k
char team[3]
for(i=0i<=2i++) //穷举
{
team[0]=buff2[i]
for(j=0j<=2j++)
{
team[1]=buff2[j]
for(k=0k<=2k++)
{
team[2]=buff2[k]
if(i==j || i==k || j==k) //不可一人出场两次
continue
if(team[0]=='x') //a不和x比
continue
if(team[2]=='x' || team[2]=='z') //c不和x\z比
continue
printf("[a,%c] [b,%c] [c,%c]",team[0],team[1],team[2])
}
}
}
return 0
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)