Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. void show() {
  2.         char zeroHp[3] = "";    zeroHp[2] = '\0';
  3.         char zeroEn[3] = "";    zeroEn[2] = '\0';
  4.         char zeroIq[3] = "";    zeroIq[2] = '\0';
  5.         char zeroSa[3] = "";    zeroSa[2] = '\0';
  6.         char zeroEx[3] = "";    zeroEx[2] = '\0';
  7.  
  8.         for(int i = 0; i < 2; ++i) {
  9.             if(log10(hp)+1 < 3 - i) zeroHp[i] = '0';
  10.             if(log10(iq)+1 < 3 - i) zeroIq[i] = '0';
  11.             if(log10(sanity)+1 < 3 - i) zeroSa[i] = '0';
  12.             if(log10(energy)+1 < 3 - i) zeroEn[i] = '0';
  13.             if(log10(excitement)+1 < 3 - i) zeroEx[i] = '0';
  14.         }
  15.  
  16.         cout << name << " " << surname << ": ";
  17.         cout << "HP = " << zeroHp << hp << ", ";
  18.         cout << "Energy = " << zeroEn << energy << ", ";
  19.         cout << "IQ = " << zeroIq << iq << ", ";
  20.         cout << "Sanity = " << zeroSa << sanity << ", ";
  21.         cout << "Excitement = " << zeroEx << excitement << ".";
  22.  
  23.         if(is_alive())
  24.             cout << '\n';
  25.         else
  26.             cout <<  " Game over." << '\n';
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement