c#day03
c#中的随机数
Random random = new Random(); //随机1~200之间的一个数 random.Next(,);
//怪兽:防御为10,血量为10
//玩家:随机8~12的攻击力
//描述怪兽掉血的情况,每次伤害大于防御则扣攻击力-防御的血,否则不扣血 public void Games()
{
Random random = new Random();
int defense = ;
int hp = ;
int atk; while (hp!=)
{ atk = random.Next(,); if(atk>defense)
{
hp = hp - ( atk - defense);
Console.WriteLine("本次攻击力为{0}------当前怪兽的血量为:{1}", atk, hp);
}
else
{
Console.WriteLine("本次攻击力为{0} ------未破防",atk);
} }
Console.WriteLine("恭喜你成功击杀了怪兽!"); }
//输入一串数字,把它换成对应的中文大写 例如123 一二三;
public void Conversion()
{
int num;
int teml = ;
string snum;
Console.WriteLine ("请输入一串数字");
snum = Console.ReadLine();
num = int.Parse(snum);
for (int i = ; i < snum.Length;i++ )
{
teml = teml * + num % ;
num = num / ;
}
for (int j = ; j < snum.Length; j++)
{
switch (teml%)
{
case :
Console.Write("零");teml = teml / ;continue;
case :
Console.Write("一");teml = teml / ; continue;
case :
Console.Write("二");teml = teml / ; continue;
case :
Console.Write("三");teml = teml / ; continue;
case :
Console.Write("四");teml = teml / ; continue;
case :
Console.Write("五");teml = teml / ; continue;
case :
Console.Write("六");teml = teml / ; continue;
case :
Console.Write("七");teml = teml / ; continue;
case :
Console.Write("八");teml = teml / ; continue;
case :
Console.Write("九");teml = teml / ; continue;
}
}
Console.WriteLine();
}
c#day03的更多相关文章
- 传智播客JavaWeb day03
ServletContext 这堂课主要讲ServletContext这个web域(可以看得见范围的)对象,web在启动的时候会创建唯一的ServletContext域对象. 作用:1.用来web域共 ...
- Java基础毕向东day03
Java基础毕向东day03 1.变量 2.条件结构 3.循环结构,for while,和几种特殊的情况. 4.函数重载
- My way to Python - Day03
列表和字典的赋值 dict1 = {} dict1['k1'] = 'v1' list1 = [] list1.append('v1') 集合系列 1,计数器 Python 2.7.6 (defaul ...
- Oracle DB Day03(SQL)
--day03 --创建一个包含下面信息的表,并添加一些记录待用 --EMPLOYEE_ID NOT NULL NUMBER(6) --FIRST_NAME VARCHAR2(20) --LAST_N ...
- python day03笔记总结
2019.3.29 S21 day03笔记总结 昨日回顾及补充 1.运算符补充 in not in 2.优先级 运算符与运算符之间也有优先级之分 今日内容 一.整型(int) py2 与 py3 的区 ...
- Python基础-day03
写在前面 上课第三天,打卡: 不要让干净的灵魂染上尘埃,永远年轻.永远热泪盈眶 一.再谈编码 - 文件的概念 '文件' 是一个抽象的概念,是操作系统提供的外部存储设备的抽象,对应底层的硬盘:它是程序 ...
- day03用户交互、基本数据类型、运算符
用户交互 在实际应用中,我们经常需要用户输入相应信息,根据用户输入信息进行反馈,此时我们需要input/output信息 python中提供了便捷的输入方法input()和print() 在pytho ...
- html--笔记day03
html--笔记day03 1.结构标记 1.<header>元素 <header></header> ==> <div id="header ...
- Day03 javascript详解
day03 js 详解 JavaScript的基础 JavaScript的变量 JavaScript的数据类型 JavaScript的语句 JavaScript的数组 JavaScript的函数 Ja ...
- python开发学习-day03(set集合、collection系列 、深浅拷贝、函数)
s12-20160116-day03 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: ...
随机推荐
- 51cto-spring boot(一Spring4快速入门)
https://search.maven.org/classic 查找maven依赖的pom.xml文件
- Cassandra--JAVA访问Cassandra数据
JAVA创建Cluster对象 cluster = Cluster.builder() .addContactPoints(contactPoints) .withRetryPolicy(new Lo ...
- No MaterialLocalizations found (Flutter)
在显示SimpleDialog时候程序报错 No MaterialLocalizations found 没有找到 MaterialLocalizations 搜索找到原因 runApp 需要先调用 ...
- 洛谷 3295 [SCOI2016]萌萌哒——并查集优化连边
题目:https://www.luogu.org/problemnew/show/P3295 当要连的边形如 “一段区间内都是 i 向 i+L 连边” 的时候,用并查集优化连边. 在连边的时候,如果要 ...
- tornado输入-get_query_argument()等 笔记
最外面的代码结构 import tornado.web import tornado.ioloop import tornado.options import tornado.httpserver f ...
- win10:如何开启自带虚拟机
1.首先要找到控制面板,我们点开windows键,然后选择在所有应用中找到“Windows 系统”,打开之后,我们找到“控制面板”,打开. 2.打开控制面板之后,我们选择程序,如图示. 3 ...
- ionic cordova platform --help
ionic platform add android 给我报这个问题,不理解 The platform command has been renamed. To find out more, run: ...
- Combobox中禁止鼠标中键滚动list列表
//第1种方法 procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; Mo ...
- Django 链接mysql
第一步:settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'testdjango ...
- 生成OSIDAAuto.OPCServer失败
来源:https://pisquare.osisoft.com/message/13441 A failuare of generating OSIDAAuto.OPCServer dorislipe ...