tungggg

dragon

Apr 13th, 2022 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.     int head=3 , tail =3 ;
  5.     int * a= new int [9];
  6.     for (int i=0;i<9;i++){
  7.         cin >> a[i];
  8.     }
  9.     for (int i=0;i<9;i++){
  10.         int x=a[i];
  11.  
  12.         if( (x!=1 && x!=2 && x!=3 && x!=4) || tail<0 || head<0  ){
  13.             cout<<"invalid attack"<<endl;
  14.             return 0;
  15.         }
  16.         if ( x== 1 ){
  17.  
  18.         }
  19.         else if ( x==2 ){
  20.             tail++;
  21.         }
  22.         else if (x==4  ){
  23.             head++;
  24.             tail-=2;
  25.         }
  26.         else if ( x==3 ){
  27.             head-=2;
  28.         }
  29.     }
  30.     if ( head <= 0 && tail<=0 )cout<<"You slayed the Dragon.";
  31.     else cout<<"You die.";
  32.     return 0;
  33. }
Add Comment
Please, Sign In to add comment