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();
            }
        }
    }

  • 相关阅读:
    tf.nn.in_top_k的用法
    随机初始化值randint,rand,tf.random_normal,tf.random_uniform
    归一化输入向量
    softmax函数理解
    梯度下降与反向传播
    深度学习-初始化权重矩阵
    学习--流畅的Python
    基础函数学习
    eclipse
    初学python
  • 原文地址:https://www.cnblogs.com/zhang-2052975439/p/4133624.html
Copyright © 2011-2022 走看看