csansoon

Consolidation 3 P44649 F012A. La vaca miop

Dec 30th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. void print(vector < vector<char> > v) {
  6.     for (int i=0; i<v[0].size(); ++i) {
  7.         for (int j=0; j<v.size(); ++j) {
  8.             cout<<v[j][i];
  9.         }
  10.         cout<<endl;
  11.     }
  12. }
  13.  
  14. int main() {
  15.     int m,s,v;
  16.     cin>>m>>s>>v;
  17.     vector < vector <char> > camp(1,vector <char> (m,'|'));
  18.     camp[0][s] = '=';
  19.     camp.push_back(vector <char> (m,'.'));
  20.     camp[1][v] = 'V';
  21.     int n=1;
  22.     bool up=false;
  23.     while (v!=s) {
  24.         for (int i=0; v!=s and i<n; ++i) {
  25.             if (up) v--;
  26.             else v++;
  27.            
  28.             if (v<0) {v++;break;} else if (v>=m){v--;break;} //"Rebotar" cuando llega al límite del campo.
  29.            
  30.             camp.push_back(vector <char> (m,'.'));
  31.             camp[camp.size()-1][v] = 'V';
  32.             //print(camp);
  33.         }
  34.         n*=2;
  35.         if (up) up = false;
  36.         else up = true;
  37.     }      
  38.     print(camp);
  39. }
  40.  
  41.  
  42. //            (__)   "MUUU"
  43. //             ()    /
  44. //     /-------\/
  45. //    / |     ||
  46. //   *  ||----||
  47. //      ~~    ~~
  48. // (c) Carlos Sansón (Best pro1 delegate ever for sure) @csansoon
Advertisement
Add Comment
Please, Sign In to add comment