zoukankan      html  css  js  c++  java
  • 方法---------拖延,清屏,前景色,背景色

    1、拖延

    System.Threading.Thread.Sleep(100);

    100--100毫秒

    例子:

    Console.WriteLine("你好"); //显示“你好!”
    System.Threading.Thread.Sleep(2000); //拖2秒进行下一步
    Console.WriteLine("你也是!"); //显示“你也是!”
    System.Threading.Thread.Sleep(2000); //拖2秒进行下一步

    console.readline();//输入---默认输入字符串

    2、清屏

     Console.Clear();

    前景色/背景色

    Console.ForegroundColor=ConsoleColor.Blue;
    Console.BackgroundColor = ConsoleColor.Blue;

    抽奖滚动案例:

    Console.WriteLine("本期中奖号码:12345");
    System.Threading.Thread.Sleep(100);
    Console.Clear();
    Console.WriteLine("本期中奖号码:54645");
    System.Threading.Thread.Sleep(100);
    Console.Clear();
    Console.WriteLine("本期中奖号码:45647");
    System.Threading.Thread.Sleep(100);
    Console.Clear();
    Console.WriteLine("本期中奖号码:123456");

    练习题

     //输入手机号,显示中奖号
            static void Main(string[] args)
            {   //输入
                Console.WriteLine("请输入要抽奖的人数:");
                int renshu = Convert.ToInt32(Console.ReadLine());
                //输入要抽奖人的手机号   
                string[] no = new string[renshu];
                for (int i = 0; i < renshu; i++)
                {
                    Console.Write("请输入抽奖人的手机号:");
                    no[i] = Console.ReadLine();
                }
                Console.WriteLine("所有人的手机号已经输入,请按回车键开始抽奖:");
                Console.Clear();
                //运算+输出
                Random rand = new Random();
                for (int i = 0; i < 30; i++)
                {
                    Console.Clear();
                    int a = rand.Next(renshu);
                    Console.WriteLine("本期中奖号码为:{0}", no[a]);
                    System.Threading.Thread.Sleep(100);//实现滚动效果
                }
    
            }
  • 相关阅读:
    codeforces 689 E. Mike and Geometry Problem 组合数学 优先队列
    01 编程 | 边界问题
    Leetcode 445. 两数相加 II
    Leetcode 485. 最大连续1的个数
    005.字符串输入与字符统计
    Leetcode 002. 两数相加
    000 Python常识与快捷键(未完)
    002 第一个Python简易游戏
    001 Python中的变量和字符串
    004.数组的不同遍历方式
  • 原文地址:https://www.cnblogs.com/jinshui/p/5431497.html
Copyright © 2011-2022 走看看