3. 有红、黄、蓝、白、黑五种颜色的球若干个,每次取出三个球,打印出三种不同颜色球的可能取法。要求分别使用字符串“red”,“yellow”,“blue”,“white”,“black”表示5种不同颜色的球。
#include<stdio.h>
#define N 5
typedef char Type;
int main()
{
int i,j,q;
Type* a[N] = { "red","yellow","blue","white","black" };
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
for (q = 0; q < N; q++)
{
if (a[i] != a[j] && a[j] != a[q]&&a[i]!=a[q])
{
printf("%s %s %s\n", a[i], a[j], a[q]);
}
}
}
}
return 0;
}