Advertisement
vakho

Bus Problem

Oct 11th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. /*
  8. +------------------------+
  9. |O.O.O.#.#.#.#.#.#.#.#.|D|)
  10. |O.O.O.#.#.#.#.#.#.#.#.|.|
  11. |O.......................|
  12. |O.O.#.#.#.#.#.#.#.#.#.|.|)
  13. +------------------------+
  14. */
  15.  
  16. void doStuff(char A[11][4], int &k) {
  17.     for (int i = 0; i < 11; i++) {
  18.         for (int j = 3; j >= 0; j--) {
  19.             if (A[i][j] == '#' && k != 0) {
  20.                 A[i][j] = 'O';
  21.                 k--;
  22.             }
  23.         }
  24.     }
  25. }
  26.  
  27. void printBus(char A[11][4]) {
  28.     for (int j = 3; j >= 0; j--) {
  29.        
  30.         // +------------------------+
  31.         if (j == 3) {
  32.             for (int l = 0; l < 26; l++) {
  33.                 if (l == 0 || l == 25) {
  34.                     cout << "+";
  35.                     continue;
  36.                 }
  37.                 cout << "-";
  38.             }
  39.             cout << endl;
  40.         }
  41.        
  42.         for (int i = 0; i <= 11; i++) {
  43.             if (i == 11) {
  44.                 switch (j) {
  45.                     case 0: cout << "|.|)"; break;
  46.                     case 1: cout << "..|";  break;
  47.                     case 2: cout << "|.|";  break;
  48.                     case 3: cout << "|D|)"; break;
  49.                 }
  50.                 continue;
  51.             }
  52.             if (i == 0) {
  53.                 cout << "|";
  54.             }
  55.             cout << A[i][j] << '.';
  56.         }
  57.         cout << endl;
  58.  
  59.         // +------------------------+
  60.         if (j == 0) {
  61.             for (int l = 0; l < 26; l++) {
  62.                 if (l == 0 || l == 25) {
  63.                     cout << "+";
  64.                     continue;
  65.                 }
  66.                 cout << "-";
  67.             }
  68.             //cout << endl;
  69.         }
  70.     }
  71. }
  72.  
  73. int main() {
  74.  
  75.     system("COLOR F0");
  76.  
  77.     int k(0);
  78.     cin >> k;
  79.  
  80.     char A[11][4] = {
  81.         {'#', '#', '#', '#'},
  82.         {'#', '.', '#', '#'},
  83.         {'#', '.', '#', '#'},
  84.         {'#', '.', '#', '#'},
  85.         {'#', '.', '#', '#'},
  86.         {'#', '.', '#', '#'},
  87.         {'#', '.', '#', '#'},
  88.         {'#', '.', '#', '#'},
  89.         {'#', '.', '#', '#'},
  90.         {'#', '.', '#', '#'},
  91.         {'#', '.', '#', '#'}
  92.     };
  93.  
  94.     doStuff(A, k);
  95.     printBus(A);
  96.  
  97.     //system("PAUSE");
  98.     return 0;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement