拿球
#include<stdio.h>enum color {red,yellow,blue,white,black};
int main()
{
enum color a, b, c, pir;
int n = 0,loop;
for (a = red; a <= black; a++)
{
for (b = red; b <= black; b++)
{
if (a != b)
{
for (c = red; c <= black; c++)
{
if (c != a && c != b)
{
n++;
printf("第%d个组合:\n", n);
for (loop = 1; loop <= 3; loop++)
{
switch (loop)
{
case 1:pir = a; break;
case 2:pir = b; break;
case 3:pir = c; break;
default:break;
}
switch (pir)
{
case red
:printf("%s", "红"); break;
case yellow:printf("%s", "黄"); break;
case 2:printf("%s", "蓝"); break;
case 3:printf("%s", "白"); break;
case 4:printf("%s", "黑"); break;
default:break;
}
}
printf("\n");
}
}
}
}
}
}
页:
[1]