• 适合新手的案例


     class Program
    {
    static void Main(string[] args)
    {
    //投掷子的游戏
    Console.WriteLine("Today,we play one game:");
    Console.WriteLine("_________________________________________By Mr.w");

    for (int i = 0; i < 10; i++)
    {
    Console.Write("*");
    Thread.Sleep(500);//让程序在这个时候停顿0.5秒
    }

    Console.WriteLine("The game is staring!");

    Random rannum = new Random();

    //第一个数:
    Console.WriteLine("please waiting....catching the first number");
    for (int a = 0; a < 5; a++)
    {

    Console.Write("*");
    Thread.Sleep(500);//让程序在这个时候停顿0.5秒
    }
    Console.WriteLine();
    int i1 = rannum.Next(1, 6);
    Console.WriteLine("The first number is {0}", i1);


    //第二个数字:
    Console.WriteLine("please waiting....catching the second number");
    for (int i = 0; i < 5; i++)
    {

    Console.Write("*");
    Thread.Sleep(500);//让程序在这个时候停顿0.5秒
    }
    Console.WriteLine();
    int i2 = rannum.Next(1, 6);
    Console.WriteLine("The second number is {0}", i2);


    int sum = i1 + i2;
    Console.WriteLine("The Sum number is {0}", sum);



    if (sum == 7 || sum == 11)
    {
    Console.WriteLine("congration to Gamer!");
    }

    if (sum == 2 || sum == 3 || sum == 11)
    {
    Console.WriteLine("sorry,you are lose.");
    }

    if (sum == 4 || sum == 5 || sum == 6 || sum == 8 || sum == 9 || sum == 10)
    {
    int temp=sum;
    Console.WriteLine("The Sum number is {0}", temp);
    Console.WriteLine("please go on catching...and the next number equal to Sum");
    for (int s = 0; s <= 3; s++)
    {

    i1 = rannum.Next(1, 6);
    Console.WriteLine("The first number is {0}", i1);

    i2 = rannum.Next(1, 6);
    Console.WriteLine("The second number is {0}", i2);
    sum = i1 + i2;
    Console.WriteLine("The Sum number is {0}", sum);


    if (sum == temp)
    {
    Console.WriteLine("The Gamer is Winer!");
    return;
    }

    if (sum == 7)
    {
    Console.WriteLine("you are loser!");
    return;
    }
    }
    }
    }
    }
  • 相关阅读:
    Redis5.x五种数据类型常见命令
    Redis5.x安装以及常见数据类型
    《Redis5.x入门教程》正式推出
    PPT制作套路指南
    如何更优雅地对接第三方API
    软件开发要质量还是要效率?
    前后端分离对于开发人员的挑战
    Spring中老生常谈的FactoryBean
    消费端如何保证消息队列MQ的有序消费
    《ElasticSearch6.x实战教程》之实战ELK日志分析系统、多数据源同步
  • 原文地址:https://www.cnblogs.com/IAmBetter/p/2286325.html
Copyright © 2020-2023  润新知