【滚动抽奖 c++】

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Reflection_/article/details/83213393

临时用,不严谨。mark一下,刚刚能完成功能,后面修改完善

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include<string.h>
#include <iostream>
#include<conio.h>
#define random(x) (rand()%x)

using namespace std;
void display(int x);

int main() {

	srand((int)time(0));
	int Num = 0;
	cout << endl << endl << "              按键开始" << endl << "        Press any key to Start";
	_getch();
	system("cls");

	char c;
	while(1){
		Num = random(400);
		display(Num);
		Sleep(50);
		if (GetAsyncKeyState('P')) {
			system("pause");
		}
		system("cls");
	}
	return 0;
}

void display(int x) {
	cout << endl << endl << "              按p键暂停" << endl << "        Press ‘p’ key to Suspend";
	cout << endl << endl;
	cout << "           luck Number:" << x <<endl<<endl<<endl;
}

初始
初始

滚动
滚动
暂停,后面依然可以继续
暂停,然后可继续

ps:这种垃圾代码没得必要去骗3个积分吧~~(误)直接拿去用就完事儿了。

猜你喜欢

转载自blog.csdn.net/Reflection_/article/details/83213393