3
已解决
廖睿轩
新手光能
新手光能
#include<bits/stdc++.h>
#include <time.h>
#include <Windows.h>
typedef struct //记录雨滴的结构体
{
int x, y;
char ch;
}RAIN**;
const int BUFFER_SIZE = 100;
int WIDTH = 80;
int HEIGHT = 30;
const int RAIN_LENGTH = 18;
RAIN** raindropLine[BUFFER_SIZE];
HANDLE HOUT = GetStdHandle(STD_OUTPUT_HANDLE);//获得标准输出的句柄
void gotoxy(int x, int y)
{
COORD pos; //定义表示一个字符在控制台屏幕上的坐标的对象
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(HOUT, pos); //设置控制台标准输出光标位置
}
void show_cursor(BOOL hide)
{
CONSOLE_CURSOR_INFO cciCursor;
if (GetConsoleCursorInfo(HOUT, &cciCursor)) //获得光标信息
{
cciCursor.bVisible = hide; //隐藏光标
SetConsoleCursorInfo(HOUT, &cciCursor); //重新设置光标
}
}
void set_color(int color)
{
SetConsoleTextAttribute(HOUT, color); //设置输出颜色
}
int main()
{
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(HOUT, &info); //获得控制台窗体信息
HEIGHT = info.srWindow.Bottom; //根据控制台的宽高设置显示的宽高
WIDTH = info.srWindow.Right;
show_cursor(FALSE);
srand((unsigned int)time(NULL));
for (int i=0; i<BUFFER_SIZE; i++) //随机设置雨滴下落的位置
{
raindropLine[i].x = rand()%WIDTH;
raindropLine[i].y = rand()%HEIGHT;
raindropLine[i].ch = rand() %2 + 48; //设置雨滴内容0或1
}
while(true)
{
GetConsoleScreenBufferInfo(HOUT, &info); //当窗体大小变化时,重新设置宽高信息
HEIGHT = info.srWindow.Bottom;
WIDTH = info.srWindow.Right;
for (int i=0; i<BUFFER_SIZE; ++i)
{
if (raindropLine[i].y <= HEIGHT)
{
gotoxy(raindropLine[i].x, raindropLine[i].y);
set_color(FOREGROUND_GREEN); //设置雨滴颜色
putchar(raindropLine[i].ch);
}
gotoxy(raindropLine[i].x, raindropLine[i].y - RAIN_LENGTH); //擦除过长的雨滴
putchar(' ');
raindropLine[i].y++;
raindropLine[i].ch = rand() % 2 + 48;
if (raindropLine[i].y > HEIGHT + RAIN_LENGTH)
{
raindropLine[i].x = rand() % WIDTH;
raindropLine[i].y = rand() % HEIGHT;
}
if ( raindropLine[i].y <= HEIGHT)
{
gotoxy(raindropLine[i].x, raindropLine[i].y);
set_color(FOREGROUND_GREEN|FOREGROUND_INTENSITY); //高亮最下方的雨滴
putchar(raindropLine[i].ch);
}
}
Sleep(50);
}
getchar();
return 0;
}
0
0
0
0
席清源
修练者
修练者
试试这个
#include<bits/stdc++.h>
using namespace std;
int main()
{
char cmd[]={'c','o','l','o','r',' ','3','0','\0'};
BEGIN:
system(cmd);
cout<<"0 1 0 1 1 0 0 0 1 1 0 1 1 1 4 2 5 3 6 3 6 3 6 3 6 3 6 4 5 5\n";
Sleep(1);
cout<<"4 2 6 3 6 3 6 3 5 3 5 3 5 3 4 3 5 2 6 3 6 3 5 3 5 3 5 3 5 3\n";
Sleep(1);
cout<<"4 2 4 6 3 5 6 8 5 4 6 8 5 7 3 4 5 3 5 3 5 5 3 5 3 4 3 3 4 3\n";
Sleep(1);
// cmd[6]=(rand()%10)+'0';
cmd[7]=(rand()%10)+'0';
goto BEGIN;
return 0;
}
0
0
0
0