C# 实现的美丽的夜空屏幕保护程序的代码

将做工程过程经常用的代码片段记录起来,下面的代码内容是关于C# 实现的美丽的夜空屏幕保护程序的代码,希望对各朋友有一些用途。

using System;
class set_cursor2
{

int lastnum;

private int RandomNumber(int min, int max)
{
Random random = new Random();
lastnum = random.Next(min, max);

if (lastnum%3 == 0 || lastnum%4==0 )
{
lastnum = random.Next(min, max);
}

if (lastnum%5 == 0 || lastnum%6==0 || lastnum%7==0 )
{
lastnum = random.Next(min, max);
}

return lastnum;
}

static void Main(string[] args)
{
set_cursor2 obj = new set_cursor2();
int lastrow,lastcol;
int i,j,t;
Console.ResetColor();
Console.Clear();
Console.SetWindowSize(100,50);
Console.BufferHeight = 500;
Console.BufferWidth = 200;
Console.CursorSize = 50;
Console.CursorVisible = true;

i = 1;
do
{
j= obj.RandomNumber(1,99);
Console.CursorLeft = j;
lastcol = j;
j= obj.RandomNumber(1,49);
lastrow = j;
Console.CursorTop = j;
if (i%3 == 0)
Console.ForegroundColor = ConsoleColor.White;
else if (i%4 == 0)
Console.ForegroundColor = ConsoleColor.Cyan;
else
Console.ForegroundColor = ConsoleColor.DarkBlue;

if ((i+j) % 2 == 0 || (i+j) % 3 == 0 || (i+j) % 5 == 0)
Console.WriteLine(" ");
else
Console.WriteLine(".");

for(t=0;t<19999999;t++);
i++;
}

while (i<=10000);
Console.WriteLine("nn Finish");
Console.ReadLine();
}

}




 

posted @ 2020-06-05 16:25  可爱小星星  阅读(279)  评论(0)    收藏  举报