版权声明:Hi,I m Debroon【Q:23609099,青睐互动 https://blog.csdn.net/qq_41739364/article/details/86765018
本程序运行在 C/C++手机编译器 ' C4droid [Google开发],需要下载可以加入QQ群:827074745
#include<iostream>
#include<conio.h> // 非标准头文件
using namespace std;
#define Rain { gotoxy(b[i][0],b[i][1]); \
cout<<"\033[22;32m"<<c<<"\033[0m"; }
//宏定义实现语句合体, 也可以用{}
#define Clear { gotoxy(b[i][0],j); cout<<" "; } // gotoxy(x,y) 是定位到(x,y)
int b[60] [2];
int main(void)
{
srand((unsigned int)time(NULL)); // 随机数种子
while(1)
{
for( int i = 0; i < 60; i ++ )
{
if(++b[i] [1] > 60) //下落,判断屏幕底
{
for( int j = 0; j <= 110; j ++)
{
Clear; //清除这列
b[i] [0] = rand( )%118+1; //x
b[i] [1] = rand( )%50; //y
}
}
if( b[i] [1] >= 0 )
{
char c = rand( )%(94-33+1)+33; // 产生随机数范围
Rain;
}
}
usleep(10000); // 暂停函数,别的编译器可能是 sleep 或 Sleep
}
return 0;
}