zoukankan      html  css  js  c++  java
  • 闲的无聊写了个很(wu)有(liao)意(dao)思(bao)的程序

    下午机房断网了

    闲的无聊,写了个小游戏

    忘了sleep在哪个库里了。。

    自带变色效果哦

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<cmath>
     5 #include<stdlib.h>
     6 #include<ctime>
     7 using namespace std;
     8 const int MAXN=0x7fffff;
     9 const int INF=50;
    10 inline int read()
    11 {
    12     char c=getchar();int f=1,x=0;
    13     while(c<'0'||c>'9')    {if(c=='-')    f=-1;c=getchar();}
    14     while(c>='0'&&c<='9')    x=x*10+c-48,c=getchar();return x*f;
    15 }
    16 struct god
    17 {
    18     int blood;
    19     int attack;
    20 }lgj;
    21 struct lgj_de_son
    22 {
    23     int blood;
    24     int attack;
    25 }lyq;
    26 inline void sleep()
    27 {
    28     int tot=0;
    29     for(int i=1;i<=2*1e8;i++)    tot++;
    30 }
    31 string myname;
    32 string enemyname;
    33 int main()
    34 {
    35     srand((unsigned)time(NULL));
    36     system("color b");
    37     printf("please input your name
    ");
    38     cin>>myname;
    39     printf("please input your blood
    ");
    40     cin>>lgj.blood;
    41     printf("please input your attack
    ");
    42     cin>>lgj.attack;
    43     printf("please input your enemy's name
    ");
    44     cin>>enemyname;
    45     printf("please input your enemy's blood
    ");
    46     cin>>lyq.blood;
    47     printf("please input your enemy's attack
    ");
    48     cin>>lyq.attack;
    49     int now=0;
    50     while(lgj.blood>0&&lyq.blood>0)
    51     {
    52         if(now==0)
    53         {
    54             sleep();
    55             system("color a");
    56             now^=1;
    57             cout<<myname;
    58             printf(" will attack  ");
    59             sleep();
    60             int k=rand()%5*lgj.attack;
    61             cout<<enemyname;
    62             printf(" 's blood -%d
    ",k);
    63             lyq.blood-=k;
    64             cout<<enemyname;
    65             printf(" 's blood remain %d
    ",lyq.blood);
    66             sleep();
    67         }
    68         else
    69         {
    70             system("color e");
    71             sleep();
    72             now^=1;
    73             cout<<enemyname;
    74             printf(" will attack  ");
    75             sleep();
    76             int k=rand()%5*lyq.attack;
    77             cout<<myname;
    78             printf("'s blood -%d
    ",k);
    79             lgj.blood-=k;
    80             sleep();
    81             cout<<myname;
    82             printf("'s blood remain %d
    ",lgj.blood);
    83         }
    84     }
    85     system("color b");
    86     if(lgj.blood<0)    printf("*********lyq win************");
    87     else             printf("*********lgj win************");
    88     return 0;
    89 }
  • 相关阅读:
    Request功能
    Request继承体系
    HTTP协议:请求消息的数据格式---Request
    HTTP协议---HttpServlet
    hdu 1575 矩阵连乘2
    hdu 1005 Number Sequence(矩阵连乘+二分快速求幂)
    矩阵连乘
    MongoDB(六):选择字段、限制记录数、排序记录
    MongoDB(五):更新文档、删除文档
    爬虫(八):文件处理
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/7737825.html
Copyright © 2011-2022 走看看