C++抽卡模拟器

发布时间:2026/10/22 20:36:07

C++抽卡模拟器 近日在学校无聊写了个抽卡模拟器供大家娱乐。代码实现以下功能抽卡界面抽卡判定、动画播放、存档。广告位前言 – 人工智能学习网1.抽卡界面及判定技术有限不可能做的和原神一样精致。代码如下注这不是完整代码别复制错了printf(enter your name:); cin username; HANDLE handle GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_CURSOR_INFO CursorInfo; GetConsoleCursorInfo(handle, CursorInfo); CursorInfo.bVisible false; SetConsoleCursorInfo(handle, CursorInfo); printf(For each time : 0.6%% for gold and 6%% for purple\n); printf(P(gold) will increase After 73 times until 90 to 100%\n); printf(10 purples , as well as 1 gold, provides another chance\n); system(pause); char kk _getch(); if (kk c) change(); int r, waidegold 0, ggold 0, pple 0; READ(); srand(time(0)); int n, m, i, j, gold 0, pp 0, big 0, cnt 0, total 30; while (cnt total) { system(cls); printf(Press 1.10\n); printf(Youve rolled %d times rest:%d\n, cnt * 10, (total - cnt) * 10); printf(WAI:%d GOLD:%d PP:%d\n, waidegold, ggold, pple); cnt; char k; bool chu 0; k _getch(); Sleep(5); for (i 1; i 10; i) { int r random(); gold, pp; if (r p[gold] *MAXX ) { total; //gold Play(1); chu 1; if ((rand() % 2 ) !big) { //wai big 1; string tmp changzhu[rand() % 8]; printf(%d times 恭喜你歪%s了\n, gold, tmp.c_str()); DATA[cnttt] username; DATA[cnttt] ( gold / 10 0); DATA[cnttt] (gold % 10 0 ); DATA[cnttt] times : ; DATA[cnttt] tmp; //printf(DATA[%d] %s\n, cnttt, DATA[cnttt].c_str()); Sleep(2000); system(pause); waidegold; } else { big 0; printf(%d times %s\n, gold, UP.c_str()); DATA[cnttt] username; DATA[cnttt] ( gold / 10 0); DATA[cnttt] (gold % 10 0 ); DATA[cnttt] times : ; DATA[cnttt] UP; //printf(DATA[%d] %s\n, cnttt, DATA[cnttt].c_str()); Sleep(2000); system(pause); ggold; } gold 0; } if (r MAXX * 0.94 || pp 10) { //purple if (!chu) Play(0); chu 1; printf(%d times a purple\n, pp); system(pause); pp 0; pple; if (pple % 10 0) total; } } }2.存档包括时间获取以及存储结果获取时间struct Time { int year, month, day, hour, minute, second; }; Time gottime() { Time TIME; time_t now time(0); tm *ltm localtime(now); TIME.year 1900 ltm-tm_year; TIME.month 1 ltm-tm_mon; TIME.day ltm-tm_mday; TIME.hour ltm-tm_hour; TIME.minute ltm-tm_min; TIME.second ltm-tm_sec; return TIME; }存储void read() { freopen(ouhuang.txt, r, stdin); scanf(%d %d %d, mxxwdgd, mxxggd, mxxple); fclose(stdin); } void putt(int waidegold, int ggold, int pple) { freopen(ouhuang.txt, w, stdout); printf(%d %d %d, waidegold, ggold, pple); fclose(stdout); } void save(int waidegold, int ggold, int pple) { read(); printf(RECORD: waide:%d not:%d ple:%d\n, mxxwdgd, mxxggd, mxxple); if (ggold mxxggd) { printf(NEW RECORD!!!\n); putt(waidegold, ggold, pple); Sleep(3000); } } string changzhu[8] ; string UP; void READ() { freopen(text.txt, r, stdin); cin UP; for (int i 0; i 7; i) cin changzhu[i]; fclose(stdin); } void change() { freopen(text.txt, w, stdout); string st; cin st; cout st endl; for (int i 1; i 8; i) { cin st; cout st endl; } fclose(stdout); } void read1() { freopen(data.txt, r, stdin); char tmp[500]; while (~scanf(%s, tmp)) { DATA[cnttt] tmp; } fclose(stdin); } void data1(string stt) { freopen(data.txt, w, stdout); Time s gottime(); printf(\n%d/%d/%d,%d:%d:%d\n, s.year, s.month, s.day, s.hour, s.minute, s.second); printf(%s\n, username.c_str()); for (int i 1; i cnttt; i) { if (DATA[i] : || DATA[i 1] :) printf(%s, DATA[i].c_str()); else printf(%s\n, DATA[i].c_str()); } fclose(stdin); fclose(stdout); }对了由于不是很信任rand()自己造了一个随机函数int random() { int a[6], k 0; for (int i 0; i 6; i) a[i] rand() % 10; for (int i 0; i 6; i) k k * 10 a[i]; return k; }3.动画播放十分简陋。void Play(bool ggg) { system(cls); if (ggg 0) { setcolor(purple, white); } else { setcolor(black, yellow); } int i, j, k; for (i 1; i 20; i) { GoToxy(i, i 20) ; printf(\\); Sleep(40); if (ggg 1) Sleep(15); } i 20, j 50, k 1; int r 1; if (ggg 1) for (; r 10; r k, k) { GoToxy(i - r, i 20 - r); for (int i1 i - r; i1 i r; i1) printf(_); for (int i1 i - r 1; i1 i r - 1; i1) { GoToxy(i1, i 20 - r); printf(|); GoToxy(i1, i 20 r); printf(|); } GoToxy(i r, i 20 - r); for (int i1 i - r; i1 i r; i1) printf(_); Sleep(55); } system(cls); setcolor(white, black); }就是这样完整代码如下。使用教程抽卡模拟器~_哔哩哔哩_bilibili#include bits/stdc.h #include windows.h #include conio.h using namespace std; const int MAXX 1e6; string username; string DATA[500000]; int cnttt 0; struct Time { int year, month, day, hour, minute, second; }; Time gottime() { Time TIME; time_t now time(0); tm *ltm localtime(now); TIME.year 1900 ltm-tm_year; TIME.month 1 ltm-tm_mon; TIME.day ltm-tm_mday; TIME.hour ltm-tm_hour; TIME.minute ltm-tm_min; TIME.second ltm-tm_sec; return TIME; } enum Colour {black, blue, green, palegreen, red, purple, yellow, white, gray, light_blue, light_palegreen, light_red, light_purple, light_yellow, light_white}; //注有些是词生造出来的可能与实际不符仅供参数使用切勿实际使用否则后果自负 const Colour Const[16] {black, blue, green, palegreen, red, purple, yellow, white, gray, light_blue, light_palegreen, light_red, light_purple, light_yellow, light_white}; double p[90] {}; void GoToxy(int y, int x) { COORD coord; coord.X x; coord.Y y; HANDLE a GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(a, coord); } void color(int x) { int typeface x / 16, background x % 16; char command_typeface[2], command_background[2]; string command color ; string change 0123456789abcdef; command command change[typeface] change[background]; char cmd[9]; for (int i 0; i 9; i) cmd[i] command[i]; system(cmd); } void setcolor(Colour x, Colour y) { int i, j; for (i 0; i 16; i) if (x Const[i]) break; for (j 0; j 16; j) if (y Const[j]) break; color(i y * 16); } int random() { int a[6], k 0; for (int i 0; i 6; i) a[i] rand() % 10; for (int i 0; i 6; i) k k * 10 a[i]; return k; } int mxxwdgd, mxxggd, mxxple; void Play(bool ggg) { system(cls); if (ggg 0) { setcolor(purple, white); } else { setcolor(black, yellow); } int i, j, k; for (i 1; i 20; i) { GoToxy(i, i 20) ; printf(\\); Sleep(40); if (ggg 1) Sleep(15); } i 20, j 50, k 1; int r 1; if (ggg 1) for (; r 10; r k, k) { GoToxy(i - r, i 20 - r); for (int i1 i - r; i1 i r; i1) printf(_); for (int i1 i - r 1; i1 i r - 1; i1) { GoToxy(i1, i 20 - r); printf(|); GoToxy(i1, i 20 r); printf(|); } GoToxy(i r, i 20 - r); for (int i1 i - r; i1 i r; i1) printf(_); Sleep(55); } system(cls); setcolor(white, black); } void read() { freopen(ouhuang.txt, r, stdin); scanf(%d %d %d, mxxwdgd, mxxggd, mxxple); fclose(stdin); } void putt(int waidegold, int ggold, int pple) { freopen(ouhuang.txt, w, stdout); printf(%d %d %d, waidegold, ggold, pple); fclose(stdout); } void save(int waidegold, int ggold, int pple) { read(); printf(RECORD: waide:%d not:%d ple:%d\n, mxxwdgd, mxxggd, mxxple); if (ggold mxxggd) { printf(NEW RECORD!!!\n); putt(waidegold, ggold, pple); Sleep(3000); } } string changzhu[8] ; string UP; void READ() { freopen(text.txt, r, stdin); cin UP; for (int i 0; i 7; i) cin changzhu[i]; fclose(stdin); } void change() { freopen(text.txt, w, stdout); string st; cin st; cout st endl; for (int i 1; i 8; i) { cin st; cout st endl; } fclose(stdout); } void read1() { freopen(data.txt, r, stdin); char tmp[500]; while (~scanf(%s, tmp)) { DATA[cnttt] tmp; } fclose(stdin); } void data1(string stt) { freopen(data.txt, w, stdout); Time s gottime(); printf(\n%d/%d/%d,%d:%d:%d\n, s.year, s.month, s.day, s.hour, s.minute, s.second); printf(%s\n, username.c_str()); for (int i 1; i cnttt; i) { if (DATA[i] : || DATA[i 1] :) printf(%s, DATA[i].c_str()); else printf(%s\n, DATA[i].c_str()); } fclose(stdin); fclose(stdout); } int main() { for (int i 1; i 72; i) p[i] 0.006; p[73] 0.01; p[74] 0.05; p[75] 0.21; p[76] 0.3; p[77] 0.33; p[78] 0.36; p[79] 0.40; p[80] 0.5; p[81] 0.6; p[82] 0.7; p[83] 0.8; p[84] 0.82; p[85] 0.9; p[86] 0.95; p[87] 0.989; p[88] 0.999; p[89] 0.999; p[90] 1; printf(enter your name:); cin username; HANDLE handle GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_CURSOR_INFO CursorInfo; GetConsoleCursorInfo(handle, CursorInfo); CursorInfo.bVisible false; SetConsoleCursorInfo(handle, CursorInfo); printf(For each time : 0.6%% for gold and 6%% for purple\n); printf(P(gold) will increase After 73 times until 90 to 100%\n); printf(10 purples , as well as 1 gold, provides another chance\n); system(pause); char kk _getch(); if (kk c) change(); int r, waidegold 0, ggold 0, pple 0; READ(); srand(time(0)); int n, m, i, j, gold 0, pp 0, big 0, cnt 0, total 30; while (cnt total) { system(cls); printf(Press 1.10\n); printf(Youve rolled %d times rest:%d\n, cnt * 10, (total - cnt) * 10); printf(WAI:%d GOLD:%d PP:%d\n, waidegold, ggold, pple); cnt; char k; bool chu 0; k _getch(); Sleep(5); for (i 1; i 10; i) { int r random(); gold, pp; if (r p[gold] *MAXX ) { total; //gold Play(1); chu 1; if ((rand() % 2 ) !big) { //wai big 1; string tmp changzhu[rand() % 8]; printf(%d times 恭喜你歪%s了\n, gold, tmp.c_str()); DATA[cnttt] username; DATA[cnttt] ( gold / 10 0); DATA[cnttt] (gold % 10 0 ); DATA[cnttt] times : ; DATA[cnttt] tmp; //printf(DATA[%d] %s\n, cnttt, DATA[cnttt].c_str()); Sleep(2000); system(pause); waidegold; } else { big 0; printf(%d times %s\n, gold, UP.c_str()); DATA[cnttt] username; DATA[cnttt] ( gold / 10 0); DATA[cnttt] (gold % 10 0 ); DATA[cnttt] times : ; DATA[cnttt] UP; //printf(DATA[%d] %s\n, cnttt, DATA[cnttt].c_str()); Sleep(2000); system(pause); ggold; } gold 0; } if (r MAXX * 0.94 || pp 10) { //purple if (!chu) Play(0); chu 1; printf(%d times a purple\n, pp); system(pause); pp 0; pple; if (pple % 10 0) total; } } } read1(); save(waidegold, ggold, pple); data1(\n); return 0; }点个赞再走吧~
延伸阅读

更多相关文章

2026/10/22 20:36:07

Office 下载安装超详细保姆级教程(附安装包)【2026最新】

文章目录第一部分:了解Office 2021第二部分:Office 2021安装步骤详解第三部分:总结大家好!本文将分步骤介绍Office 2021的安装方法,这是一份详细的指南,旨在帮助大家顺利完成安装。Office是常用的办公软件&…

2026/10/22 20:36:07

c# web发布与IIS搭建合集教程(Win11):

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/22 21:56:52

Linux下AAC编码实战:FFmpeg编码器选择与参数调优指南

跟音频编码打交道这些年,Linux 上我做得最多的事情之一,就是把各种乱七八糟的音频源转成 AAC。不是因为它有多玄乎,而是在兼容性、压缩比和音质之间,AAC 那个平衡点确实很难被替代。尤其现在流媒体、视频封装、移动端播放器几乎全…

2026/10/22 21:56:52

HDFS DataNode 核心机制与运维实战:从启动握手到故障排查

1. DataNode 在 HDFS 架构中的真实定位 很多人学 Hadoop 的时候,NameNode 和 DataNode 的关系背得滚瓜烂熟,什么“一个管元数据,一个管数据”,但真到了线上环境,DataNode 出的问题往往是最要命的——磁盘写满、块丢失、…

2026/10/22 21:56:52

多合一图像识别系统实践:从OCR到万物分类的架构与部署

最近有个朋友找我聊需求,说他们公司内部想上一套图像识别能力,要涵盖银行卡、身份证、营业执照、车牌、驾驶证、行驶证、票据这些证件票据,还要能认植物、动物、车型、Logo。一开始我想的是,这些东西各有各的成熟方案,…

2026/10/22 21:56:52

大模型流式接口压测实战:JMeter脚本实现TTFT与Token吞吐统计

大模型接口的压测,和普通接口完全是两码事。普通接口发一个 POST,等响应回来,记个时间、看个大小就完事了;流式接口建立连接之后,数据会持续往客户端推,可能几十秒才结束。这时候你光看“总响应时间”没有任…

2026/10/22 21:51:52

PyTorch Unfold 全解析:滑动窗口、Patch 提取与 Fold 避坑指南

如果你碰过 Vision Transformer 的前处理、写过图像修复里的相似块匹配,或者只是想把一张图像按固定大小、固定步长切成一堆窗口,多半会有这样的一瞬间:循环写到一半,突然意识到 PyTorch 里好像有个函数天生就是干这个的。对&…

2026/10/22 11:29:28

金融AI落地指南:从调研报告到技术选型与工程实践

简介:这份PDF报告聚焦2025年金融服务业中国AI现状与趋势,面向金融科技从业者、AI战略规划人员及关注行业数字化转型的研究者,帮助读者把握生成式AI在银行、支付、交易等场景中的落地路径与投资方向。资源包内含1个PDF文件,大小约1…

2026/10/22 0:01:49

电商智能运营体系从0到1:架构设计、落地步骤与避坑指南

前两年我们团队接了一个电商平台的运营中台项目,目标很直白:把过去靠运营拍脑袋做的选品、定价、发券、推活动这些事,逐步用数据算法和自动化流程代替。项目名字内部就叫“电商智能运营体系”。最近有不少朋友问我当时是怎么设计的、踩过哪些…

2026/10/22 0:01:49

若依框架AI代码生成不稳定?用Agent Skill三层结构+五步法搞定

最近一段时间,我一直想把后台管理系统里那些机械重复的增删改查代码交给AI去写。框架用的是若依,按理说这类业务代码模式非常固定,应该是AI最擅长的事情。可真试下来却不是那么回事——你让AI生成一个用户管理模块,它给出的Contro…

还想了解更多?直接咨询顾问

免费诊断 + 免费方案 + 透明报价。

全国咨询热线400-8866-253
免费获取方案
☎咨询二维码 ☎ ↑