我有一个双打列表,为此,假设我有一个双打,命名为一、二、三、四、五、六、七等……到 100。每个都设置为一个值。(这些值与名称不对应)。
我如何随机选择其中的 10 个,并将每个选定的设置为另一个双倍?
EG 说选择了双“一”,以及其他 9 个。
我还想将双“blah”设置为所选双精度的值。然后我想将双“blahtwo”设置为下一个选定双精度的值,等等......
我不想随机选择相同的双倍。
示例代码:
double cardone, cardtwo, cardthree, cardfour, cardfive, cardsix, cardseven, cardeight, cardnine, cardten, cardeleven, cardtwelve, cardthirteen, cardfourteen, cardfifteen, cardsixteen, cardseventeen, cardeighteen, cardnineteen, cardtwenty;
double ran, ranone, rantwo, ranthree, ranfour, ranfive, ransix, ranseven, raneight, rannine, ranten;
cardone = 1.01;
cardtwo = 1.02;
cardthree = 1.03;
cardfour = 1.04;
cardfive = 1.05;
cardsix = 1.06;
cardseven = 1.07;
cardeight = 1.08;
cardnine = 1.09;
cardten = 1.1;
cardeleven = 1.11;
cardtwelve = 1.12;
cardthirteen = 1.13;
cardfourteen = 2.01;
cardfifteen = 2.02;
cardsixteen = 2.03;
cardseventeen = 2.04;
cardeighteen = 2.05;
cardnineteen = 2.06;
cardtwenty = 2.07;
所以我想随机选择十个名字为“card”的双打,例如。卡多内、卡二等
我想要名为“跑”的双打,例如。“ranone”“rantwo”等...设置为与十个选定的双打相同。