HUST Online Judge WebBoard
Problem 128732 >> 古代战争模拟器(v.05.07.004).cpp
zhaodongqiang @ 2024-09-16 14:50:14
[ Quote ] [ Edit ] [ Delete ] 1#
#include<bits/stdc++.h>
#include<Windows.h>
using namespace std;
int fy,gj;
int main() {
cout<<"欢迎进入古代战争模拟器(v.05.07.004).cpp版本"<<endl;
Sleep(3000);
system("cls");
cout<<"本游戏由恒远工作室(室长zhaodongqiang制作)"<<endl<<endl;
cout<<"本工作室成员有赵东强,孙翊宸,余子浩"<<endl<<endl;
Sleep(3000);
system("cls");
int i;
cout<<"开始加载游戏......"<<endl;
Sleep(2000);
system("cls");
for(i=1;i<=70;i+=(rand()%5+1)){
printf("加载中%d%%",i);
system("cls");
}
for(i=i+1;i<=98;i++){
printf("加载中%d%%",i);
Sleep(200);
system("cls");
}
printf("加载中99%%");
Sleep(5000);
system("cls");
printf("加载成功!");
Sleep(2000);
system("cls");
cout<<"请输入你的姓"<<endl<<endl;
string x;
cin>>x;
cout<<endl;
system("cls");
cout<<"公元1年"<<endl<<endl;
cout<<"你联合自家兵团创建了"<<x<<"家军"<<endl<<endl;
long long f=500;
cout<<x<<"家军"<<"共有"<<f<<"人"<<endl<<endl;
int q;
cout<<"请选择你要攻打的城市"<<endl<<endl;
cout<<"1.合肥(守兵2000人) 2.长丰(守兵1000人) 3.黄山(守兵200人)"<<endl<<endl;
cin>>q;
cout<<endl;
int jdxr=100;
if(q==1){
cout<<"你领兵500向合肥进攻"<<endl<<endl;
Sleep(3000);
cout<<"你惨遭战败,兵团500人全部阵亡"<<endl<<endl;
Sleep(3000);
cout<<"你被敌人活捉后惨遭杀害"<<endl<<endl;
Sleep(3000);
system("cls");
cout<<"游戏失败"<<endl<<endl;
}else if(q==2){
cout<<"你领兵500向长丰进攻"<<endl<<endl;
Sleep(3000);
cout<<"你惨遭战败,兵团500人阵亡300人"<<endl<<endl;
Sleep(3000);
cout<<"你领军撤退"<<endl<<endl;
Sleep(3000);
system("cls");
int t;
int rq=2;
f=f-300;
int r=3000;
while(f>0&&r>=0){
cout<<"公元"<<rq<<"年"<<endl<<endl;
cout<<"军队人数:"<<f<<" 钱数:"<<r<<" 攻击:"<<gj<<" 防御:"<<fy<<endl<<endl;
cout<<"你选择 1.招兵买马(增加军队200人) 2.进攻它地(概率领土扩大,否则军队伤亡) 3.搞钱 4.商城"<<endl<<endl;
cin>>t;
int zdq=0;
if(t==1){
cout<<"你获得了200人"<<endl<<endl;
cout<<"军队增加到"<<f+200<<"人"<<endl<<endl;
f=f+200;
cout<<"钱数减少1000"<<endl<<endl;
cout<<"钱数减少到"<<r-1000<<endl<<endl;
r=r-1000;
Sleep(3000);
}else if(t==2){
int w;
if(w%2!=0){
cout<<"你战胜了!"<<endl<<endl;
cout<<"你获得了2000元,100人"<<endl<<endl;
r=r+2000;
f=f+100;
Sleep(3000);
zdq++;
if(zdq==100){
cout<<"游戏胜利!!!"<<endl<<endl;
cout<<"感谢您的游玩!!!"<<endl<<endl;
cout<<"再见!!!"<<endl;
break;
}
}else{
cout<<"你战败了"<<endl<<endl;
cout<<"军队减少1000"<<endl<<endl;
f=f-1000;
Sleep(3000);
}
}else if(t==3){
cout<<"你要投资药品吗?"<<endl<<endl;
cout<<"1.投 2.不投"<<endl<<endl;
int bt;
cin>>bt;
if(bt==1){
cout<<"输入你要投多少"<<endl<<endl;
double qw;
cin>>qw;
int xr;
if(qw>r){
zhaodongqiang @ 2024-09-16 14:50:56
[ Quote ] [ Edit ] [ Delete ] 2#
cout<<"拜拜"<<endl<<endl;
Sleep(3000);
break;
}else{
if(xr<=100){
r=r-qw;
cout<<"投的钱数*1.5"<<endl<<endl;
qw=qw*1.5;
r=r+qw;
}else{
r=r-qw;
cout<<"投的钱数/1.5"<<endl<<endl;
qw=qw/1.5;
r=r+qw;
}
}
}else if(bt==2){
cout<<"6"<<endl<<endl;
}else if(t==4){
cout<<"欢迎来到商城"<<endl<<endl;
cout<<"在这里你可以买到你需要的东西"<<endl<<endl;
cout<<"1.防具 1000元(增加1000防御) 2.武器 10000元(增加5000攻击) 3.返回"<<endl<<endl;
int tre;
cin>>tre;
if(tre==1){
if(r>=1000){
cout<<"购买成功!!!"<<endl<<endl;
r=r-1000;
fy=fy+1000;
Sleep(3000);
system("cls");
}else{
cout<<"抱歉你的钱数不够,购买失败......"<<endl<<endl;
Sleep(3000);
system("cls");
}
}else if(tre==2){
if(r>=10000){
cout<<"购买成功!!!"<<endl<<endl;
Sleep(3000);
system("cls");
r=r-10000;
gj=gj+5000;
}else{
cout<<"抱歉你的钱数不够,购买失败......"<<endl<<endl;
Sleep(3000);
system("cls");
}
}else if(t==3){
}
}else{
cout<<"抱歉,输入错误,结束游戏!"<<endl<<endl;
Sleep(3000);
break;
}
}else{
cout<<"抱歉,输入错误,结束游戏!"<<endl<<endl;
Sleep(3000);
break;
}
rq++;
system("cls");
jdxr--;
if(jdxr<=0){
break;
}
}
system("cls");
cout<<"游戏失败"<<endl;
}else if(q==3){
cout<<"你领兵500向黄山进攻"<<endl<<endl;
Sleep(3000);
cout<<"你战胜敌军,获得200军队"<<endl<<endl;
Sleep(3000);
cout<<"你占领黄山,你在黄山建立了叛军根据地"<<endl<<endl;
Sleep(3000);
system("cls");
int t;
int rq=2;
f=f+200;
int r=3000;
while(f>0&&r>=0){
cout<<"公元"<<rq<<"年"<<endl<<endl;
cout<<"军队人数:"<<f<<" 钱数:"<<r<<" 攻击:"<<gj<<" 防御:"<<fy<<endl<<endl;
cout<<"你选择 1.招兵买马(增加军队200人) 2.进攻它地(概率领土扩大,否则军队伤亡) 3.搞钱 4.商城"<<endl<<endl;
cin>>t;
if(t==1){
cout<<"你获得了200人"<<endl<<endl;
cout<<"军队增加到"<<f+200<<"人"<<endl<<endl;
f=f+200;
cout<<"钱数减少1000"<<endl<<endl;
cout<<"钱数减少到"<<r-1000<<endl<<endl;
Sleep(3000);
r=r-1000;
}else if(t==2){
int w=rand();
int zdq=0;
if(w%2!=0){
cout<<"你获得了2000元,100人"<<endl<<endl;
r=r+2000;
f=f+100;
Sleep(3000);
zdq++;
if(zdq==100){
cout<<"游戏胜利!!!"<<endl<<endl;
cout<<"感谢您的游玩!!!"<<endl<<endl;
cout<<"再见!!!"<<endl;
zhaodongqiang @ 2024-09-16 14:51:11
[ Quote ] [ Edit ] [ Delete ] 3#
break;
}
}else{
cout<<"你战败了"<<endl<<endl;
cout<<"军队减少500"<<endl<<endl;
f=f-500;
Sleep(3000);
}
}else if(t==3){
cout<<"你要投资药品吗?"<<endl<<endl;
cout<<"1.投 2.不投"<<endl<<endl;
int bt;
cin>>bt;
if(bt==1){
cout<<"输入你要投多少"<<endl<<endl;
double qw;
cin>>qw;
int xr;
if(qw>r){
cout<<"抱歉,输入错误,结束游戏!"<<endl<<endl;
Sleep(3000);
break;
}else{
if(xr<=100){
r=r-qw;
cout<<"投的钱数*1.5"<<endl<<endl;
qw=qw*1.5;
r=r+qw;
}else{
r=r-qw;
cout<<"投的钱数/1.5"<<endl<<endl;
qw=qw/1.5;
r=r+qw;
}
}
}else if(bt==2){
cout<<"6"<<endl<<endl;
}
}else if(t==4){
cout<<"欢迎来到商城"<<endl<<endl;
cout<<"在这里你可以买到你需要的东西"<<endl<<endl;
cout<<"1.防具 1000元(增加1000防御) 2.武器 10000元(增加5000攻击) 3.返回"<<endl<<endl;
int tre;
cin>>tre;
if(tre==1){
if(r>=1000){
cout<<"购买成功!!!"<<endl<<endl;
r=r-1000;
fy=fy+1000;
Sleep(3000);
system("cls");
}else{
cout<<"抱歉你的钱数不够,购买失败......"<<endl<<endl;
Sleep(3000);
system("cls");
}
}else if(tre==2){
if(r>=10000){
cout<<"购买成功!!!"<<endl<<endl;
Sleep(3000);
system("cls");
r=r-10000;
gj=gj+5000;
}else{
cout<<"抱歉你的钱数不够,购买失败......"<<endl<<endl;
Sleep(3000);
system("cls");
}
}else if(t==3){
}
}else{
cout<<"抱歉,输入错误,结束游戏!"<<endl<<endl;
Sleep(3000);
break;
}
rq++;
system("cls");
jdxr--;
if(jdxr<=0){
break;
}
}
system("cls");
cout<<"游戏失败"<<endl<<endl;
}else{
cout<<"抱歉,输入错误,结束游戏!"<<endl<<endl;
Sleep(3000);
}
return 0;
}
luoen @ 2024-09-17 20:45:45
[ Quote ] [ Edit ] [ Delete ] 4#
厉害
yuchenye @ 2025-08-16 16:41:33
[ Quote ] [ Edit ] [ Delete ] 5#
cvxbfg
sunyicheng @ 2025-08-29 15:36:28
[ Quote ] [ Edit ] [ Delete ] 6#
我名字打错了
zhangxuanzhen @ 2025-08-30 10:24:24
[ Quote ] [ Edit ] [ Delete ] 7#
@zhaodongqiang我来帮你优化一下
zhangxuanzhen @ 2025-08-30 10:24:51
[ Quote ] [ Edit ] [ Delete ] 8#
有些地方你做的不好
luoen @ 2025-08-30 18:24:53
[ Quote ] [ Edit ] [ Delete ] 9#
比如坑人的关机系统?
zhaodongqiang @ 2025-08-31 10:23:07
[ Quote ] [ Edit ] [ Delete ] 10#
哪有关机系统
zhaodongqiang @ 2025-08-31 10:28:24
[ Quote ] [ Edit ] [ Delete ] 11#
我加的不是退出程序吗?
luoen @ 2025-09-03 19:37:06
[ Quote ] [ Edit ] [ Delete ] 12#
那可能是我记错了,反正有一个讨论版里的游戏(好像是魔鬼电梯吧)有关机程序
zhangwenbo @ 2025-09-05 19:14:21
[ Quote ] [ Edit ] [ Delete ] 13#
我的也有。。。