有红、黄、绿三种颜色的球,其中红球3个,黄球3个,绿球6个。现将这12个球放在一个盒子中,从中任意摸出8个球,编程计算摸出球的各种颜色搭配。#include<stdio.h>#include<math.h>mai... 有红、黄、绿三种颜色的球,其中红球3个,黄球3个,

绿球6个。现将这12个球放在一个盒子中,从中任意摸出8个球,

编程计算摸出球的各种颜色搭配。
#include<stdio.h>
#include<math.h>
main()
{
int red,yellow,green;
for(red=0;red<=3;red++)
for(yellow=0;yellow<=3;yellow++)
for(green=2;green<=8;green++)
if(red+yellow+green==8)
printf("%d %d %d\n",red,yellow,green);
}