mercredi 22 avril 2015

random numbers within a range, but close to the last generated number

I have some code which generates random numbers for my ints within a range, but i also want to implement it so that when it generates the next number, it cannot be greater than 3 either side of previoulsy generates number. So for example if my rbp gets a value of 140 generated, the next would be between 137&143.

Not sure how i would go about implementing this?

           timer1.Interval = 1000;
        Random r = new Random();
        int rbp = r.Next(89, 260);//BP
        int rhr = r.Next(39, 131);//HR
        int rrr = r.Next(8, 25);//RR
        int ros = r.Next(90, 120);//OS
        double rtemp = r.Next(34, 40);//Temp




Aucun commentaire:

Enregistrer un commentaire