zoukankan      html  css  js  c++  java
  • 适合新手的案例

     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;
    }
    }
    }
    }
    }
  • 相关阅读:
    .net中实现运行时从字符串动态创建对象
    C# 用 VB.net 函數庫 實現全角與半角轉換
    實現.net 加載插件方式
    VS2008下載
    Lotus Notes Send EMail from VB or VBA
    用C#写vs插件中的一些Tip
    SQL2005中异常处理消息框可直接使用
    C#路径/文件/目录/I/O常见操作汇总
    利用.net反射动态调用指定程序集的中的方法
    说说今年的计划
  • 原文地址:https://www.cnblogs.com/IAmBetter/p/2286325.html
Copyright © 2011-2022 走看看