学习2周c++ 耗时1周做了一个程序
2025-10-11 20:22:45
发布于:浙江
学习2周c++
本蒟蒻耗时1周做了一个程序
版权所有 (c) 2025 Can I play 瓦洛兰特? 保留所有权利
可以二创,需备注原作者ID 使用ACGO私信作者:“Can I play 瓦洛兰特?”获取的代码输出放在开头及备注成功
各位大佬给个赞吧,也求多多指教
这是demo测试版1.0
后面会持续更新
必看:程序的密码部分由数组组成,所以程序说“请设置新密码”时你先输入密码的位数,再输入每位的数字(可以一位以上,但不能小数),中间以空格隔开,实例:
5 //5位数字
1 2 3 45 6 //分别输入5个数字
代码如下:
//需使用dev.c++ 版本5.6.1及以上的编译器编译
#include<bits/stdc++.h>
using namespace std;
int n;//正确密码的个数
int a[1000];
int b[1000];
int s;//密码对的次数
int q;
int p,l;
int e;
void asd(int asdfg);
int main()
{
asd(1);
int w=5;
int f=0;
for(int j=1;j<=5;j++)
{
s=0;
if(w==5&&f==0)
{
cout<<"欢迎使用神秘软件"<<endl;
cout<<"请设置新密码"<<endl;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
cout<<"密码设置成功!为确保安全,请再次输入密码"<<endl;
f++;
for(int i=1;i<=n;i++)
{
cin>>b[i];
if(a[i]==b[i])
{
cout<<".";
s++;
}
}
}
else
{
goto chong;
chong:
s=0;
cout<<"请再次输入密码"<<endl;
for(int i=1;i<=n;i++)
{
cin>>b[i];
if(a[i]==b[i])
{
cout<<".";
s++;
}
}
}
if(s==n)
{
cout<<"密码正确!"<<endl;
goto jiemian;
jiemian:
cout<<"1 小游戏"<<endl;
cout<<"2 设置"<<endl;
cout<<"3 退出"<<endl;
int s1;
cin>>s1;
if(s1==1)
{
int s2;
goto youxi;
youxi:
cout<<"1 计算小游戏"<<endl<<"2 数字炸弹"<<endl<<"3 返回"<<endl;
cin>>s2;
if(s2==1)
{
s2==0;
goto youxi1;
youxi1:
cout<<endl<<"学霸都在玩的神秘游戏"<<endl;
cout<<"1 开始"<<endl<<"2 退出"<<endl;
int o1;
cin>>o1;
if(o1==1)
{
int a;
int b;
cout<<"你想做什么运算?"<<endl<<"1 加法"<<endl<<"2 减法"<<endl<<"3 乘法"<<endl<<"4 除法(只答出整数部分就行)"<<endl;
int h;
cin>>h;
cout<<"你想做几到几的运算? 输入两个数,分别是(几) 到(几)"<<endl;
cin>>a>>b;
cout<<"你想做几题?"<<endl;
cin>>e;
for(int l=e;l>=1;l+0)
{
system("cls");
srand(static_cast<unsigned>(time(0)));
int v = min(a,b) + rand() % (abs(b - a) + 1);
int m = min(a,b) + rand() % (abs(b - a) + 1);
if(h==1)
{
cout<<v<<"+"<<m<<"=?"<<endl;
for(int u=5;u>=1;u--)
{
cout<<u;
_sleep(1000);
cout<<"\b";
}
cout<<"\b";
cout<<endl;
cin>>p;
if(p!=v+m)
{
cout<<"错了!"<<endl<<"是"<<v+m<<endl;
}
else
{
l=l-1;
cout<<"对了!加油"<<endl<<"还剩"<<l<<"题"<<endl;
}
}
else if(h==2)
{
cout<<v<<"-"<<m<<"=?"<<endl;
for(int u=5;u>=1;u--)
{
cout<<u;
_sleep(1000);
cout<<"\b";
}
cout<<"\b";
cout<<endl;
cin>>p;
if(p!=v-m)
{
cout<<"错了!"<<endl<<"是"<<v-m<<endl;
}
else
{
l=l-1;
cout<<"对了!加油"<<endl<<"还剩"<<l<<"题"<<endl;
}
}
else if(h==3)
{
cout<<v<<"*"<<m<<"=?"<<endl;
for(int u=5;u>=1;u--)
{
cout<<u;
_sleep(1000);
cout<<"\b";
}
cout<<"\b";
cout<<endl;
cin>>p;
if(p!=v*m)
{
cout<<"错了!"<<endl<<"是"<<v*m<<endl;
}
else
{
l=l-1;
cout<<"对了!加油"<<endl<<"还剩"<<l<<"题"<<endl;
}
}
else if(h==4)
{
if(m!=0)
{
cout<<v<<"/"<<m<<"=?"<<endl;
for(int u=5;u>=1;u--)
{
cout<<u;
_sleep(1000);
cout<<"\b";
}
cout<<"\b";
cout<<endl;
cin>>p;
if(p!=v/m)
{
cout<<"错了!"<<endl<<"是"<<v/m<<endl;
}
else
{
l=l-1;
cout<<"对了!加油"<<endl<<"还剩"<<l<<"题"<<endl;
}
}
}
}
cout<<"游戏结束"<<endl;
_sleep(1000);
goto youxi;
}
else if(o1==2)
{
goto youxi;
}
else
{
cout<<"请重新输入"<<endl;
_sleep(1000);
goto youxi1;
}
}
else if(s2==2)
{
s2==0;
int a1=0,b1=0,n1=0;
goto zhubi;
zhubi:
cout<<"欢迎游玩数字炸弹"<<endl;
cout<<"1 开始"<<endl<<"2 退出"<<endl;
int u1;
cin>>u1;
if(u1==1)
{
int e1=100,q1=0;
cout<<"正在随机炸弹"<<endl;
_sleep(1000);
srand(static_cast<unsigned>(time(0)));
n1 = q1 + rand() % (e1 - q1 + 1);
while(1)
{
system("cls");
sb1:
cout<<"玩家1:"<<endl;
cout<<q1<<"-"<<e1<<endl;
cin>>a1;
if(a1<n1&&a1>=q1)
{
q1=a1;
q1+=1;
b1:
cout<<"玩家2:"<<endl;
cout<<q1<<"-"<<e1<<endl;
cin>>b1;
if(b1<n1&&b1>=q1)
{
q1=b1;
q1+=1;
goto sb1;
}
else if(b1>n1&&b1<=e1)
{
e1=b1;
e1-=1;
goto sb1;
}
else
{
goto b1;
}
}
if(a1>n1&&a1<=e1)
{
e1=a1;
e1-=1;
b2:
cout<<"玩家2:"<<endl;
cout<<q1<<"-"<<e1<<endl;
cin>>b1;
if(b1>n1&&b1<=e1)
{
e1=b1;
e1-=1;
goto sb1;
}
else if(b1<n1&&b1>=q1)
{
q1=b1;
q1+=1;
goto sb1;
}
else
{
goto b2;
}
}
if(a1==n1)
{
if(e1==q1)
{
for(int j1=1;j1<=5;j1++)
{
cout<<"BONG"<<endl;
}
cout<<"玩家2胜利"<<endl<<"玩家1是个欧皇!";
cout<<"游戏结束"<<endl;
goto youxi;
break;
}
else
{
for(int j1=1;j1<=5;j1++)
{
cout<<"BONG"<<endl;
}
cout<<"玩家2胜利"<<endl<<"玩家1是个欧皇!";
cout<<"游戏结束"<<endl;
goto youxi;
break;
}
}
if(b1==n1)
{
if(e1==1)
{
for(int j1=1;j1<=5;j1++)
{
cout<<"BONG"<<endl;
}
cout<<"玩家1胜利"<<endl<<"玩家2是个欧皇!";
cout<<"游戏结束"<<endl;
goto youxi;
break;
}
else
{
for(int j1=1;j1<=5;j1++)
{
cout<<"BONG"<<endl;
}
cout<<"玩家1胜利"<<endl<<"玩家2是个欧皇!";
cout<<"游戏结束"<<endl;
goto youxi;
break;
}
}
}
}
else if(u1==2)
{
goto youxi;
}
else
{
cout<<"请重新输入"<<endl;
_sleep(1000);
system("cls");
goto zhubi;
}
}
else if(s2==3)
{
goto youxi;
}
else
{
cout<<"请重新输入"<<endl;
_sleep(1000);
goto jiemian;
}
}
else if(s1==2)
{
cout<<"暂未开发"<<endl;
_sleep(1000);
goto youxi;
}
else if(s1==3)
{
goto chong;
}
}
else
{
w=w-1;
cout<<"密码错误,你还有"<<w<<"次输入机会"<<endl;
}
if(w<=0)
{
cout<<"错误次数太多,账号已永久封禁"<<endl;
w=5;
f=0;
}
}
}
//以下代码可以删除,但需私信作者
void asd(int asdgh)
{
string banquan={"本代码由 ACGO网站 用户名: Can I play 瓦洛兰特? 制作"};
l=banquan.size();
for(int i=0;i<=l-1;i++)
{
cout<<banquan[i];
_sleep(50);
}
cout<<endl;
string banquan2={"版权所有 (c) 2025 Can I play 瓦洛兰特? 保留所有权利"};
l=banquan2.size();
for(int i=0;i<=l-1;i++)
{
cout<<banquan2[i];
_sleep(50);
}
cout<<endl;
string banquan3={"可以二创,需备注原作者ID 使用ACGO私信作者:“Can I play 瓦洛兰特?”获取的代码输出放在开头及备注成功"};
l=banquan3.size();
for(int i=0;i<=l-1;i++)
{
cout<<banquan3[i];
_sleep(50);
}
cout<<endl;
_sleep(2000);
system("cls");
}
各位大佬给个赞吧,也求多多指教
这里空空如也
有帮助,赞一个