在C#中随机 [英] Random in c#

查看:88
本文介绍了在C#中随机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在学校里做运动,不知道如何解决,请您能帮我吗? :doh:

锻炼:

编写一个程序,该程序随机生成1到50范围内的100个整数值.您的程序应显示在1..10、11 .. 20等范围内发生了多少个生成的数字.
例如,您的程序可能显示:

Hello to all,

I have an exercise for my school and I have no idea how to solve it, can you please help me? :doh:

Exercise:

Write a program that randomly generates 100 integer values in the range 1 to 50. Your program should display how many numbers of the numbers generated occurred in the range 1..10, 11.. 20, etc.
For example, your program might display:

1..10  20
11..20 25
21..30 12
31..40 23
41..50 20



非常感谢您!



Thank you very much!

推荐答案

如果不直接给您答案,否则我会做您的作业,并且您从未听说过google或阅读过您的课程笔记;

1)使用RANDOM类
2)创建一个数组来存储5个类别
3)根据类别限制检查返回的随机数,并增加存储在相关数组索引中的值
4)显示输出
5)根据需要重复
Without giving you the answer directly, otherwise i would be doing YOUR homework, and you have never heard of google or read your course notes;

1) use the RANDOM class
2) create an array to store the 5 categories
3) check the returned random number against the category limits and increment the value stored in the relevant array index
4) display the output
5) repeat as required


这篇关于在C#中随机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆