C++代码雨

这篇文章介绍了使用C++编写的程序,通过监听A、B、C键的按下,控制输出预设的字符数组,实现了动态的代码雨效果。
摘要由CSDN通过智能技术生成

3,2,1 上链接 上代码!

#include<bits/stdc++.h>
#include<Windows.h>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#define ll long long
#define un unsigned
using namespace std;
int getRand(ll min,ll max){
	return (rand()%(max-min+1))+min;
}
string a[5]={"0","1"," "};
string b[100]={"\n","0","1"," ","0","1"," ","0","1"," ","0","1"," ","0","1"," ","0","1"," ","0","1"," "};
string c[100]={"0","1"," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "};
int main(){
	srand(time(0));
	system("color 2");
	cout<<"代码雨一按A\n代码雨二按B\n代码雨三按C";
	while(1){
		if(KEY_DOWN('A')) while(1) cout<<a[getRand(0,4)];
		if(KEY_DOWN('B')) while(1) cout<<b[getRand(0,25)];
		if(KEY_DOWN('C')) while(1) cout<<c[getRand(0,24)];
	}
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值