C++彩票机
代码实现
#include <bits/stdc++.h>
#include <windows.h>
#include <ctime>
#include<cstdlib>
using namespace std;
void ccc(string s) {
for(int i = 0; i < s.size(); i++) {
cout << s[i];
Sleep(25);
}
cout << "\n";
}
int main() {
system("color 06");
srand((unsigned)time(NULL));
ccc(" 欢迎进入彩票生成系统!");
ccc(" 奖金最高888积分!");
cout << "\n\n\n";
ccc(" 你要几张?");
cout << " ";
int a;
cin >> a;
int s = 0;
while(a--) {
cout << "\n";
ccc(" 彩票正在生成中……");
cout << "\n";
Sleep(500);
int n = rand() % 20 + 1;
cout << "中奖序号" << n;
cout << "\n\n\n";
for(int i = 1; i <= 8; i++) {
int x = ((rand() % 200 + 1) / 50 + 1) * 5;
int y = rand() % 20 + 1;
printf("序号:%d 奖金:%d\n\n", y, x);
if(y == n) s += x;
Sleep(1000);
}
}
printf("奖金:%d元!", s);
Sleep(10 * 1000);
}