问题描述
解决方案
解决方案二:
三个数字以w为改变因子做综合为8的排列组合
解决方案三:
有人问过和你一模一样的问题在帖子中我也有答复
解决方案四:
引用2楼crystal_lz的回复:
有人问过和你一模一样的问题在帖子中我也有答复
int nCount = 8;//总共拿出个数int nRedCount = 100;int nWriteCount = 100;int nBlackCount = 1;for (int write = 1; write <= nWriteCount && write <= nCount; write++) { for (int red = 0; red <= nRedCount && (write + red) <= nCount; red++) { //黑球不够凑够8个的情况下的情况下 if (nCount - write - red > nBlackCount) continue; Console.WriteLine( "write:" + write + " red:" + red + " black:" + (nCount - write - red)); }} write:1 red:6 black:1write:1 red:7 black:0write:2 red:5 black:1write:2 red:6 black:0write:3 red:4 black:1write:3 red:5 black:0write:4 red:3 black:1write:4 red:4 black:0write:5 red:2 black:1write:5 red:3 black:0write:6 red:1 black:1write:6 red:2 black:0write:7 red:0 black:1write:7 red:1 black:0write:8 red:0 black:0