C#实验2.4
来源:互联网 发布:中华书局 知乎 编辑:程序博客网 时间:2024/06/06 08:54
随机给出一个0-99之间的数字,然后猜数字。
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { guess(); } static void guess() { Console.WriteLine("随机给出0-99的数字,猜猜这个数"); Random ran = new Random(); int k = ran.Next(0, 99); int realNumber = k; // Console.WriteLine("程序随机分配的值为:{0}", realNumber); int yourGuess = 0; Console.WriteLine("输入你的猜测:"); yourGuess = int.Parse(Console.ReadLine()); while (yourGuess != realNumber) { if (yourGuess > realNumber) { Console.WriteLine("猜大了,再输入你的猜测:"); yourGuess = int.Parse(Console.ReadLine()); } else if(yourGuess<realNumber) { Console.WriteLine("猜小了,再输入你的猜测:"); yourGuess = int.Parse(Console.ReadLine()); } } Console.WriteLine("猜对了!"); Console.ReadKey(); } }}
运行结果:
0 0
- C#实验2.4
- C#实验
- C#实验[1]
- C#实验[2]
- C#实验[3]
- C#实验[4]
- c#实验6作业
- C#实验8
- C#中的编码实验
- C#实验题目
- C# 实验课
- C#实验笔记
- C#实验上机
- C#我文本框实验
- C#多线程实验
- C#上机实验
- C#实验十1.1
- C#实验十1.2
- mysql 主从搭建
- java 集合框架
- Spark 启动脚本——sbin/start-slaves.sh
- 获取info
- UVa 10054 - The Necklace
- C#实验2.4
- Spark集群搭建——SSH免密码验证登陆
- JPA & Hibernate 注解
- Spark中的编程模型
- 垃圾车定律
- Spark源码分析之Worker
- POJ 2452 Sticks Problem
- DICOM文件下载
- Spark RDD详解