.Net基础篇_学习笔记_第七天_随机数的产生
2024-09-01 08:17:47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 第六天_流程语句
{
class Program
{
static void Main(string[] args)
{
Random r = new Random(); //1.创建一个能产生随机数的对象
while (true)
{
int _numR = r.Next(, ); //2.让产生随机数的这个对象 调用方法来产生随机数 能取到1到不能取到10,左闭右开区间。
Console.WriteLine(_numR);
Console.ReadKey();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 第六天_流程语句
{
class Program
{
static void Main(string[] args)
{
Random r = new Random(); //1.创建一个能产生随机数的对象
while (true)
{
int _numR = r.Next(, ); //2.让产生随机数的这个对象 调用方法来产生随机数 能取到1到不能取到7,左闭右开区间。6种可能
Console.WriteLine("请输入您的名字:");
string _name = Console.ReadLine(); //伪代码,对下面操作无影响
switch (_numR)
{
case :
Console.WriteLine("你上辈子是个大臣");
break;
case :
Console.WriteLine("你上辈子是个诸侯");
break;
case :
Console.WriteLine("你上辈子是个农民");
break;
case :
Console.WriteLine("你上辈子是个王子");
break;
case :
Console.WriteLine("你上辈子是个公主");
break;
default:
Console.WriteLine("你上辈子是个侍女");
break; }
Console.ReadKey();
}
}
}
}
最新文章
- 从零构建JavaScript的对象系统
- linux线程同步(5)-屏障
- python 字符串 转 dict
- ural 1215 Exactness of Projectile Hit
- sql server varchar(10)和 nvarchar(10)存储数据长度
- 用VBA宏从一个工作薄复制内容到另一个工作薄
- windows下oracle数据库定时备份与压缩批处理脚本(win7/win2008亲测通过)
- 【记录】Spring项目转化为Spring Web项目
- css之幽灵空白节点
- 说一说MVC的CompressActionFilterAttrubute(五)
- Windows服务器环境下jenkins下载和安装
- .NET简单学习
- BZOJ3172 [Tjoi2013]单词 字符串 SA ST表
- 读取excel日期数据问题
- [JXOI2018]游戏 (线性筛,数论)
- kafka后台启动的命令
- [Android] Service服务详解以及如何使service服务不被杀死
- centos7: svbversion版本的安装配置+tortoisesvn登录验证
- HBase——使用Put迁移MySql数据到Hbase
- python三大神器之迭代器
热门文章
- C# ModBus 读取数据
- Nacos(六):多环境下如何“管理”及“隔离”配置和服务
- shell习题1
- Linux命令行中好用的快捷键
- 为了完成这个功能,我竟然用5行代码制作了一个EXE可执行程序
- Selenium3 + Python3自动化测试系列九——cookie操作
- Codeforces 936B
- BigDecimal 使用浅析
- Leetcode之深度优先搜索(DFS)专题-473. 火柴拼正方形(Matchsticks to Square)
- C#开发BIMFACE系列17 服务端API之获取模型数据2:获取构件材质列表