zoukankan      html  css  js  c++  java
  • 猜数字小游戏(创建一个控制台。。。原理:random 产生随机数)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace eluosi
    {
        class Program
        {
            static void Main(string[] args)
            {
                new Program().play();
            }
            void play()
            {
                Random r = new Random();
                int j = r.Next(1, 10);
                int i;
                int n=1;
                Console.Write("猜猜随机数是多少(1~10):");
                do
                {
                    i = int.Parse(Console.ReadLine());
                    if (i == j)
                    {
                        Console.Write("恭喜你在第{0}次猜对了", n);
                    }
                    else
                    {
                        if (i < j)
                        {
                            Console.Write("第{0}次,小了", n);
                        }
                        else
                        {
                            Console.Write("第{0}次,大了", n);
                        }
                    }
                    n++;
                } while (i != j);
                Console.ReadLine();
            }
        }
    }

  • 相关阅读:
    运维文档的几点看法
    cmpp短信网关对接MSGID问题
    一文带解读C# 动态拦截覆盖第三方进程中的函数(外挂必备)
    C#中的解构
    如何科学破解慢SQL?
    c# HttpClient 上传文件并带参
    React 页面跳转传值
    Mysql 优化:status这类字段适合加索引吗?
    PHP数组高效去重
    PHP unset()、array_unique()的坑
  • 原文地址:https://www.cnblogs.com/zhang-2052975439/p/4133624.html
Copyright © 2011-2022 走看看