Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- 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',' '};
- char int_to_char(int input) {
- if (input > 54) {
- return NULL;
- }
- return inttochartable[input];
- };
- int main()
- {
- /*
- * Bark: Counter increment
- * Woof: Counter decrement
- * Growl: Print
- * Yip: Print raw number
- * Howl: Current +1
- * Wimper: Current -1
- */
- int counter[256] = {0};
- int current = 0;
- cout << "Hello, and welcome to bark!" << endl;
- while (true) {
- string input;
- cin >> input;
- if (input.compare("bark")==0) {
- counter[current]++;
- }
- if (input.compare("woof")==0) {
- counter[current]--;
- }
- if (input.compare("growl")==0) {
- cout << int_to_char(counter[current]);
- }
- if (input.compare("yip")==0) {
- cout << counter[current];
- }
- if (input.compare("howl")==0) {
- if (current < 256) {
- current++;
- };
- }
- if (input.compare("whimper")==0) {
- if (current != 0) {
- current--;
- };
- }
- }
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement