习题:
有一种非常实用的抽卡概率控制算法,给定两个数组
weight = {5, 10, 100, 100, 200 }
card = {“SSR”, “SR”, “R”, “A”, “B” }
第一个weight数组代表每种卡占的权重
第二个card数组代表抽到的是什么卡
例如:R卡抽到的概率是:
100 / (5 + 10 + 100 + 100 + 200) = 100 / 415
输出:按照规定的概率,随机抽出一张卡。
using System;
namespace 数组与抽卡概率控制
{
class Program
{
static Random random = new Random();
static void Main(string[] args)
{
int[] weight = {