3
已解决
高乐彤
修练者
修练者
#include<windows.h>
#include<bits/stdc++.h>
#include <sys/stat.h>
#include <fstream>
#include <unistd.h>
#include <string>
#include <cstdlib>
#include <ctime>
#include <fstream>
int HP=25,FOOL=30,N=15,cg=0,m,fs,e;
using namespace std;
put(string s){
for(int i=0;i<s.size();i++){
cout<<s[i];
Sleep(100);
}
}
void qk(int x){
if(x==2||x==3){
int k=rand()%100+1;
if(k<=55){
int r=rand()%50+1;
if(r<=10){
int l=rand()%5+1;
cout<<"你遇到了"<<l<<"只僵尸!";
cout<<"生命-"<<l;
cout<<"。同时你花费了"<<l<<"点"<<"饱食度来打僵尸"<<endl;
HP-=l;
FOOL-=l;
}if(r>=11&&r<=15){
cout<<"你挖到了地雷!";
cout<<"你你扣掉了85%的血!\n";
HP=(double)(HP*1.00/100.0*15);
}if(r>=16&&r<=30){
cout<<"你什么也没挖到\n";
}if(r>=31&&r<=39){
cout<<"你被头顶的砂砾埋了,生命-30%\n";
HP=(double)(HP*1.00/100.0*70);
}if(r>=40){
int l=rand()%5;
cout<<"你挖空了!摔掉了"<<l<<"点血\n";
HP-=l;
cg-=l;
}
}else{
int r=rand()%10+1;
if(r==1){
int k=rand()%250+100;
cout<<"你挖到了钻石!卖得"<<k<<"元\n";
m+=k;
}if(r>=2&&r<=7){
int k=rand()%100+30;
cout<<"你挖到了铁,卖得"<<k<<"元\n";
m+=k;
}if(r>=8){
int k=rand()%150+80;
cout<<"你挖到了金!卖得"<<k<<"元\n";
m+=k;
}
}
}if(x==1){
cg--;
int k=rand()%100+1;
if(k<=40){
int r=rand()%15+1;
if(r==1||r==3){
int k=rand()%250+100;
cout<<"你挖到了钻石!卖得"<<k<<"元\n";
m+=k;
}if(r>=4&&r<=11||r==2){
int k=rand()%100+30;
cout<<"你挖到了铁,卖得"<<k<<"元\n";
m+=k;
}if(r>=12&&r<=15){
int k=rand()%150+80;
cout<<"你挖到了金!卖得"<<k<<"元\n";
m+=k;
}
}else{
int r=rand()%50+1;
if(r<=10){
int l=rand()%5+1;
cout<<"你遇到了"<<l<<"只僵尸!";
cout<<"生命-"<<l;
cout<<"。同时你花费了"<<l<<"点"<<"饱食度来打僵尸"<<endl;
FOOL-=l;
HP-=l;
}if(r>=11&&r<=30){
cout<<"你什么也没挖到\n";
}if(r>=31&&r<=40){
int l=rand()%5;
cout<<"你挖空了!摔掉了"<<l<<"点血\n";
HP-=l;
cg-=l;
}if(r>=41&&r<=47){
int l=rand()%8+2;
cout<<"你掉入了地下河!氧气含量-"<<l<<endl;
N-=l;
}if(r>=48){
cout<<"你掉入了岩浆!";
HP=0;
}
}
}
return ;
}void mk(){
system("cls");
while(true){
cout<<"你要:1买急救箱 0退出\n";
int a;
cin>>a;
system("cls");
if(a==0)return ;
if(a==1){
cout<<"1 初级急救箱 180元 可以回血3点\n";
cout<<"2 中级急救箱 300元 可以回血5点\n";
cout<<"3 高级急救箱 400元 可以回血8点\n";
cout<<"4 满级急救箱 500元 可以回血12点\n";
cout<<"----------------------------------\n";
cout<<"你有"<<m<<"元\n";
int n;
cin>>n;
if(n==1){
if(m>=180){
HP+=3;
cout<<"购买成功!!!^-^\n";
m-=180;
}else{
cout<<"买不起!\n";
}
}if(n==2){
if(m>=300){
HP+=5;
cout<<"购买成功!!!^-^\n";
m-=300;
}else{
cout<<"买不起!\n";
}
}if(n==3){
if(m>=400){
HP+=8;
cout<<"购买成功!!!^-^\n";
m-=400;
}else{
cout<<"买不起!\n";
}
}if(n==4){
if(m>=500){
HP+=12;
cout<<"购买成功!!!^-^\n";
m-=500;
}else{
cout<<"买不起!\n";
}
}
}
}
}
int main(){
srand(time(0));
cout<<"生命:25 饱食度:30 氧气含量:15 海拔:0 钱数:0\n";
while(HP>0&&FOOL>0&&N>0){
cout<<"你要:1向下挖 2向左挖 3向右挖 4进入商店 5退出\n";
int a;
cin>>a;
if(a<=3)qk(a);
if(a==0)return 0;
if(a==4)mk();
Sleep(1000);
system("cls");
cout<<"生命:"<<HP<<" 饱食度:"<<FOOL<<" 氧气含量:"<<N<<" 海拔:"<<cg<<" 钱数:"<<m<<endl;
}
system("cls");
cout<<"你over了!";
Sleep(1000);
cout<<"正在计算分数";
for(int i=1;i<=3;i++){
Sleep(250);
cout<<". ";
}
system("cls");
m=m/3*3;
while(m){
printf("钱数:%d 分数:%d\n",m,fs);
m-=3;
int k=rand()%7;
fs+=147+k;
system("cls");
}
system("cls");
put("你最终的成绩为:");
cout<<fs;
return 0;
}
更新内容:修复已知问题 结算速度再加快了1.5倍 但最大误差增加到102分(我会继续努力的!) 更新商店
0
0
0
0
0
李显晨
中级启示者
中级启示者
我更新好了,你看看
#include<windows.h>
#include<bits/stdc++.h>
#include <sys/stat.h>
#include <fstream>
#include <unistd.h>
#include <string>
#include <cstdlib>
#include <ctime>
#include <fstream>
int HP=25,FOOL=30,N=15,cg=0,m,fs,e;
using namespace std;
put(string s){
for(int i=0;i<s.size();i++){
cout<<s[i];
Sleep(100);
}
}
void qk(int x){
if(x==2||x==3){
int k=rand()%100+1;
if(k<=55){
int r=rand()%50+1;
if(r<=10){
int l=rand()%5+1;
cout<<"你遇到了"<<l<<"只僵尸!";
cout<<"生命-"<<l;
cout<<"。同时你花费了"<<l<<"点"<<"饱食度来打僵尸"<<endl;
HP-=l;
FOOL-=l;
}if(r>=11&&r<=15){
cout<<"你挖到了地雷!";
cout<<"你你扣掉了85%的血!\n";
HP=(double)(HP*1.00/100.0*15);
}if(r>=16&&r<=30){
cout<<"你什么也没挖到\n";
}if(r>=31&&r<=39){
cout<<"你被头顶的砂砾埋了,生命-30%\n";
HP=(double)(HP*1.00/100.0*70);
}if(r>=40){
int l=rand()%5;
cout<<"你挖空了!摔掉了"<<l<<"点血\n";
HP-=l;
cg-=l;
}
}else{
int r=rand()%10+1;
if(r==1){
int k=rand()%250+100;
cout<<"你挖到了钻石!卖得"<<k<<"元\n";
m+=k;
}if(r>=2&&r<=7){
int k=rand()%100+30;
cout<<"你挖到了铁,卖得"<<k<<"元\n";
m+=k;
}if(r>=8){
int k=rand()%150+80;
cout<<"你挖到了金!卖得"<<k<<"元\n";
m+=k;
}
}
}if(x==1){
cg--;
int k=rand()%100+1;
if(k<=40){
int r=rand()%15+1;
if(r==1||r==3){
int k=rand()%250+100;
cout<<"你挖到了钻石!卖得"<<k<<"元\n";
m+=k;
}if(r>=4&&r<=11||r==2){
int k=rand()%100+30;
cout<<"你挖到了铁,卖得"<<k<<"元\n";
m+=k;
}if(r>=12&&r<=15){
int k=rand()%150+80;
cout<<"你挖到了金!卖得"<<k<<"元\n";
m+=k;
}
}else{
int r=rand()%50+1;
if(r<=10){
int l=rand()%5+1;
cout<<"你遇到了"<<l<<"只僵尸!";
cout<<"生命-"<<l;
cout<<"。同时你花费了"<<l<<"点"<<"饱食度来打僵尸"<<endl;
FOOL-=l;
HP-=l;
}if(r>=11&&r<=30){
cout<<"你什么也没挖到\n";
}if(r>=31&&r<=40){
int l=rand()%5;
cout<<"你挖空了!摔掉了"<<l<<"点血\n";
HP-=l;
cg-=l;
}if(r>=41&&r<=47){
int l=rand()%8+2;
cout<<"你掉入了地下河!氧气含量-"<<l<<endl;
N-=l;
}if(r>=48){
cout<<"你掉入了岩浆!";
HP=0;
}
}
}
return ;
}void mk(){
system("cls");
while(true){
cout<<"你要:1买急救箱 2买食物 3买氧气瓶 0退出\n";
int a;
cin>>a;
system("cls");
if(a==0)return ;
if(a==1){
cout<<"1 初级急救箱 180元 可以回血3点\n";
cout<<"2 中级急救箱 300元 可以回血5点\n";
cout<<"3 高级急救箱 400元 可以回血8点\n";
cout<<"4 满级急救箱 500元 可以回血12点\n";
cout<<"----------------------------------\n";
cout<<"你有"<<m<<"元\n";
int n;
cin>>n;
if(n==1){
if(m>=180){
HP+=3;
cout<<"购买成功!!!^-^\n";
m-=180;
}else{
cout<<"买不起!\n";
}
}if(n==2){
if(m>=300){
HP+=5;
cout<<"购买成功!!!^-^\n";
m-=300;
}else{
cout<<"买不起!\n";
}
}if(n==3){
if(m>=400){
HP+=8;
cout<<"购买成功!!!^-^\n";
m-=400;
}else{
cout<<"买不起!\n";
}
}if(n==4){
if(m>=500){
HP+=12;
cout<<"购买成功!!!^-^\n";
m-=500;
}else{
cout<<"买不起!\n";
}
}
}
if(a==2){
cout<<"1 蔬菜 60元 可以回饱食度1点\n";
cout<<"2 水果 180元 可以回饱食度3点\n";
cout<<"3 海鲜 300元 可以回饱食度5点\n";
cout<<"4 肉类 600元 可以回血10点\n";
cout<<"----------------------------------\n";
cout<<"你有"<<m<<"元\n";
int n;
cin>>n;
if(n==1){
if(m>=60){
FOOL+=1;
cout<<"购买成功!!!^-^\n";
m-=60;
}else{
cout<<"买不起!\n";
}
}if(n==2){
if(m>=180){
FOOL+=3;
cout<<"购买成功!!!^-^\n";
m-=180;
}else{
cout<<"买不起!\n";
}
}if(n==3){
if(m>=300){
FOOL+=5;
cout<<"购买成功!!!^-^\n";
m-=300;
}else{
cout<<"买不起!\n";
}
}if(n==4){
if(m>=600){
FOOL+=10;
cout<<"购买成功!!!^-^\n";
m-=600;
}else{
cout<<"买不起!\n";
}
}
}
if(a==3){
cout<<"1 初级氧气罐 180元 可以回氧气3点\n";
cout<<"2 中级氧气罐 300元 可以回氧气5点\n";
cout<<"3 高级氧气罐 400元 可以回氧气8点\n";
cout<<"4 满级氧气罐 500元 可以回氧气12点\n";
cout<<"----------------------------------\n";
cout<<"你有"<<m<<"元\n";
int n;
cin>>n;
if(n==1){
if(m>=180){
N+=3;
cout<<"购买成功!!!^-^\n";
m-=180;
}else{
cout<<"买不起!\n";
}
}if(n==2){
if(m>=300){
N+=5;
cout<<"购买成功!!!^-^\n";
m-=300;
}else{
cout<<"买不起!\n";
}
}if(n==3){
if(m>=400){
N+=8;
cout<<"购买成功!!!^-^\n";
m-=400;
}else{
cout<<"买不起!\n";
}
}if(n==4){
if(m>=500){
N+=12;
cout<<"购买成功!!!^-^\n";
m-=500;
}else{
cout<<"买不起!\n";
}
}
}
}
}
int main(){
srand(time(0));
cout<<"生命:25 饱食度:30 氧气含量:15 海拔:0 钱数:0\n";
while(HP>0&&FOOL>0&&N>0){
cout<<"你要:1向下挖 2向左挖 3向右挖 4进入商店 5退出\n";
int a;
cin>>a;
if(a<=3){
qk(a);
FOOL--;
}
if(a==0)return 0;
if(a==4)mk();
Sleep(1000);
system("cls");
cout<<"生命:"<<HP<<" 饱食度:"<<FOOL<<" 氧气含量:"<<N<<" 海拔:"<<cg<<" 钱数:"<<m<<endl;
}
system("cls");
cout<<"你over了!";
Sleep(1000);
cout<<"正在计算分数";
for(int i=1;i<=3;i++){
Sleep(250);
cout<<". ";
}
system("cls");
m=m/3*3;
while(m){
printf("钱数:%d 分数:%d\n",m,fs);
m-=3;
int k=rand()%7;
fs+=147+k;
system("cls");
}
system("cls");
put("你最终的成绩为:");
cout<<fs;
return 0;
}
0
0