Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5. char inttochartable[54] = {'a','A','b','B','c','C','d','D','e','E','f','F','g','G','h','H','i','I','j','J','k','K','l','L','m','M','n','N','o','O','p','P','q','Q','r','R','s','S','t','T','u','U','v','V','w','W','x','X','y','Y','z','Z','/n',' '};
  6. char int_to_char(int input) {
  7.     if (input > 54) {
  8.         return NULL;
  9.     }
  10.     return inttochartable[input];
  11.  
  12.  
  13. };
  14. int main()
  15. {
  16.     /*
  17.     * Bark: Counter increment
  18.     * Woof: Counter decrement
  19.     * Growl: Print
  20.     * Yip: Print raw number
  21.     * Howl: Current +1
  22.     * Wimper: Current -1
  23.     */
  24.     int counter[256] = {0};
  25.     int current = 0;
  26.  
  27.     cout << "Hello, and welcome to bark!" << endl;
  28.     while (true) {
  29.     string input;
  30.     cin >> input;
  31.     if (input.compare("bark")==0) {
  32.         counter[current]++;
  33.     }
  34.     if (input.compare("woof")==0) {
  35.         counter[current]--;
  36.     }
  37.     if (input.compare("growl")==0) {
  38.         cout << int_to_char(counter[current]);
  39.         }
  40.     if (input.compare("yip")==0) {
  41.         cout << counter[current];
  42.     }
  43.     if (input.compare("howl")==0) {
  44.         if (current < 256) {
  45.             current++;
  46.         };
  47.     }
  48.     if (input.compare("whimper")==0) {
  49.         if (current != 0) {
  50.             current--;
  51.         };
  52.     }
  53.     }
  54.     return 0;
  55. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement