• CCF-炉石传说


      1 #include<cstdio>
      2 typedef struct
      3 {
      4     int attack,health;
      5 } cus;
      6 
      7 cus info[2][8];
      8 int aliv[2];
      9 int player = 0;
     10 
     11 void summon();
     12 void attack();
     13 void solven();
     14 void del(int,int);
     15 //void init();
     16 
     17 int main()
     18 {
     19     int n=0;
     20     char order[10];
     21     //init();
     22     scanf("%d",&n);
     23     info[0][0].health = 30;
     24     info[1][0].health = 30;
     25     while(n--)
     26     {
     27         scanf("%s",order);
     28         if(order[0] == 'e')
     29             player = !player;
     30         else if(order[0] == 's')
     31             summon();
     32         else if(order[0] == 'a')
     33             attack();
     34     }
     35     solven();
     36 }
     37 
     38 void summon()
     39 {
     40     int p,a,h;
     41     scanf("%d%d%d",&p,&a,&h);
     42     ++aliv[player];
     43     for(int i=aliv[player]; i>p; --i)
     44     {
     45         info[player][i].attack = info[player][i-1].attack;
     46         info[player][i].health = info[player][i-1].health;
     47     }
     48     info[player][p].attack = a;
     49     info[player][p].health = h;
     50     //init();
     51 }
     52 
     53 void attack()
     54 {
     55     int p1,p2;
     56     scanf("%d%d",&p1,&p2);
     57     if(p2 != 0)
     58     {
     59         info[player][p1].health -= info[(!player)][p2].attack;
     60         info[(!player)][p2].health -= info[player][p1].attack;
     61         if(info[player][p1].health < 1)
     62             del(player,p1);
     63         if(info[(!player)][p2].health <1)
     64             del((!player),p2);
     65     }
     66     else
     67         info[(!player)][p2].health -= info[player][p1].attack;
     68     //init();
     69 }
     70 
     71 void solven()
     72 {
     73     //init();
     74     int num;
     75     if(info[0][0].health < 1 && info[1][0].health > 0)
     76         printf("-1
    ");
     77     else if(info[1][0].health < 1 && info[0][0].health > 0)
     78         printf("1
    ");
     79     else
     80         printf("0
    ");
     81 
     82     printf("%d
    %d",info[0][0].health,aliv[0]);
     83     for(int i=1; i<=aliv[0]; ++i)
     84         printf(" %d",info[0][i].health);
     85     printf("
    ");
     86 
     87     printf("%d
    %d",info[1][0].health,aliv[1]);
     88     for(int i=1; i<=aliv[1]; ++i)
     89         printf(" %d",info[1][i].health);
     90     printf("
    ");
     91 }
     92 
     93 void del(int x,int p)
     94 {
     95     for(int i=p; i<aliv[x]; ++i)
     96     {
     97         info[x][i].attack = info[x][i+1].attack;
     98         info[x][i].health = info[x][i+1].health;
     99     }
    100     info[x][aliv[x]].attack = 0;
    101     info[x][aliv[x]].health = 0;
    102     --aliv[x];
    103 }
    104 
    105 /*void init()
    106 {
    107     puts("
    *************************");
    108     puts("player1's attack:");
    109     for(int i=0; i<8; ++i)
    110         printf("%d ",info[0][i].attack);
    111     puts("");
    112 
    113     puts("player1's health:");
    114     for(int i=0; i<8; ++i)
    115         printf("%d ",info[0][i].health);
    116     puts("");
    117 
    118         puts("player2's attack:");
    119     for(int i=0; i<8; ++i)
    120         printf("%d ",info[1][i].attack);
    121     puts("");
    122 
    123     puts("player2's health:");
    124     for(int i=0; i<8; ++i)
    125         printf("%d ",info[1][i].health);
    126     puts("");
    127     puts("*************************
    ");
    128 }*/
  • 相关阅读:
    关于C#登录三层
    SQL 语句关于分页的写法
    C# 如何去掉button按钮的边框线
    20151220
    继承
    对象的旅行
    多态
    封装
    OO大原则
    javascript
  • 原文地址:https://www.cnblogs.com/qq188380780/p/6667543.html
Copyright © 2020-2023  润新知