下午机房断网了
闲的无聊,写了个小游戏
忘了sleep在哪个库里了。。
自带变色效果哦
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stdlib.h>
#include<ctime>
using namespace std;
const int MAXN=0x7fffff;
const int INF=;
inline int read()
{
char c=getchar();int f=,x=;
while(c<''||c>'') {if(c=='-') f=-;c=getchar();}
while(c>=''&&c<='') x=x*+c-,c=getchar();return x*f;
}
struct god
{
int blood;
int attack;
}lgj;
struct lgj_de_son
{
int blood;
int attack;
}lyq;
inline void sleep()
{
int tot=;
for(int i=;i<=*1e8;i++) tot++;
}
string myname;
string enemyname;
int main()
{
srand((unsigned)time(NULL));
system("color b");
printf("please input your name\n");
cin>>myname;
printf("please input your blood\n");
cin>>lgj.blood;
printf("please input your attack\n");
cin>>lgj.attack;
printf("please input your enemy's name\n");
cin>>enemyname;
printf("please input your enemy's blood\n");
cin>>lyq.blood;
printf("please input your enemy's attack\n");
cin>>lyq.attack;
int now=;
while(lgj.blood>&&lyq.blood>)
{
if(now==)
{
sleep();
system("color a");
now^=;
cout<<myname;
printf(" will attack ");
sleep();
int k=rand()%*lgj.attack;
cout<<enemyname;
printf(" 's blood -%d\n",k);
lyq.blood-=k;
cout<<enemyname;
printf(" 's blood remain %d\n",lyq.blood);
sleep();
}
else
{
system("color e");
sleep();
now^=;
cout<<enemyname;
printf(" will attack ");
sleep();
int k=rand()%*lyq.attack;
cout<<myname;
printf("'s blood -%d\n",k);
lgj.blood-=k;
sleep();
cout<<myname;
printf("'s blood remain %d\n",lgj.blood);
}
}
system("color b");
if(lgj.blood<) printf("*********lyq win************");
else printf("*********lgj win************");
return ;
}