题目描述
一个口袋中放有12个球,已知其中3个是红的,3个是白的,6个是黑的,现从中任取8个,问共有多少种可能的颜色搭配?
代码
#include <stdio.h>
int main()
{
int red = 0, white = 0, black = 0;
int cnt = 0;
for(red = 0; red <= 3; red++)
for(white = 0; white <=3; white++)
for(black = 0; black <= 6; black++)
if(red + white + black == 8)
{
printf("%-2d --- %d个红球,%d个黑球,%d个黑球\n",
++cnt, red, white, black);
}
printf("总共有%d种搭配.\n", cnt);
return 0;
}
标签:中放有,cnt,int,问题,色球,include,red
From: https://www.cnblogs.com/drip3775/p/17383014.html