啊哈磊_编程从这里起步
标题:
水库V1.0.0
[打印本页]
作者:
code0001
时间:
2019-11-24 20:02
标题:
水库V1.0.0
一个简单的程序,
其实就是买卖水,
但是,效果还可以。
#include <iostream>
#include <cstdio>
#include <windows.h>
#include <time.h>
using namespace std;
int main()
{
int i,j,k,s=100,money=1000,ss=500,day=0,t[11]={0},x[11]={0},b[11]={0},p,pt,note=1,sss,v,max_money=1000,tq;
char a;
system("color 17");
printf("欢迎来到《水库》\n");
printf("这个游戏的目标是:合理经营水库,使你赚到更多的钱\n");
printf("现在,让我们开始吧\n");
Sleep(5000);
system("cls");
while(money>=0)
{
day++;
system("cls");
if(money>max_money)
{
max_money=money;
}
srand((unsigned)time(NULL));
tq=rand()%3;
if(tq==0)
{
s=s+200;
}
if(tq==1)
{
s=s+100;
}
if(tq==2)
{
s=s+20;
}
if(s>ss)
{
s=ss;
}
for(i=1;i<=note;i++)
{
if(t[i]!=0)
{
t[i]--;
}
else
{
money=money-b[i];
for(j=i;j<=note;j++)
{
t[j]=t[j+1];
x[j]=x[j+1];
b[j]=b[j+1];
}
note--;
}
}
if(note<=7)
{
i=note;
p=rand()%3+1;
j=rand()%101;
note=note+p;
for(i=i;i<=note;i++)
{
srand(sss);
pt=rand()%500+j;
x[i]=pt;
sss++;
t[i]=10;
b[i]=pt;
}
}
if(tq==0)
{
cout<<"昨晚,下起了大暴雨";
cout<<"\n水库加成200";
}
if(tq==1)
{
cout<<"昨晚,下起了绵绵细雨";
cout<<"\n水库加成100";
}
if(tq==2)
{
cout<<"昨晚,只有月亮高悬在空中";
cout<<"\n水库加成20";
}
cout<<"\n请选择:\n";
cout<<"j:跳过一天\n";
cout<<"s:完成订单\n";
cout<<"u:扩大水库\n";
cout<<"r:人工降雨\n";
cout<<"day:"<<day;
cout<<"\nmoney:"<<money;
cout<<"\n水库余水:"<<s<<"/"<<ss;
cout<<"\n订单条数"<<':'<<"需水量"<<' '<<"限时"<<' '<<"酬劳\n";
for(i=1;i<=note;i++)
{
cout<<i<<":"<<x[i]<<' '<<t[i]<<' '<<b[i]<<"\n";
}
cin>>a;
if(a=='j')
{
continue;
}
if(a=='s')
{
cout<<"完成第几条订单?";
cin>>v;
s=s-x[v];
if(s<0)
{
cout<<"水库枯竭,强行人工降雨";
while(s<0)
{
money=money-200;
s=s+200;
}
}
money=money+b[v];
for(j=v;j<=note;j++)
{
t[j]=t[j+1];
x[j]=x[j+1];
b[j]=b[j+1];
}
note--;
}
if(a=='u')
{
ss=ss+500;
money=money-1000;
}
if(a=='r')
{
s=s+200;
money=money-200;
}
}
cout<<"你的分数是:"<<max_money;
cout<<"欢迎下次游玩";
Sleep(5000);
return 0;
}
复制代码
水库V1.0.0.cpp
(3.38 KB, 下载次数: 3)
2019-11-24 19:57 上传
点击文件名下载附件
作品链接
第一次发帖,
不喜勿喷
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2