AlenAntonelli

Descubriendo_El_Rufian_Alen

May 12th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. ///Trello, Principiante, 2008n1p1-descubriendo-el-refran
  2. #include <iostream> ///Antonelli Alen Gabriel
  3. #include <vector>
  4. using namespace std;
  5. int main ()
  6. {
  7.     int p=0;
  8.     string aux, aux1, aux2, aux3;
  9.     cin >> p;
  10.     vector <string> v (p, ".");
  11.     for (int i=0; i<p; i++)
  12.     {
  13.         cin >> aux;
  14.         v[i]=aux;
  15.     }
  16.     for (int i=0; i<p; i++)
  17.     {
  18.         aux="";
  19.         aux=v[i];
  20.         if (aux.size()%2==0) // invertir
  21.         {
  22.             for (int j=0; j<aux.size(); j++)
  23.             {
  24.                 v[i][j]=aux[aux.size()-j-1];
  25.             }
  26.         }
  27.         if (aux.size()%2==1)
  28.         {
  29.             if (aux.size()!=1 && aux.size()!=3) // intercambiar extremos dejando las tres de el medio iguales
  30.             {
  31.                 aux1="";
  32.                 aux2="";
  33.                 aux3="";
  34.                 for (int j=0; j<aux.size(); j++) /// pu nte ro (7) - 3 = 4 / 2 = 2
  35.                 {                                /// 01 234 56
  36.                     if (j<((aux.size()-3)/2))
  37.                         aux1.push_back(aux[j]);
  38.                     if (   ((aux.size()-3)/2)<=j   &&   j<((aux.size()-3)/2)+3   )
  39.                         aux2.push_back(aux[j]);
  40.                     if (j>=((aux.size()-3)/2)+3)
  41.                         aux3.push_back(aux[j]);
  42.                 }
  43.                 v[i]=aux3+aux2+aux1;
  44.             }
  45.         }
  46.     }
  47.     for (int i=0; i<p; i++)
  48.     {
  49.         cout << v[i];
  50.         if (i<p-1)
  51.             cout<< " ";
  52.     }
  53.     cout<<".";
  54.  
  55.     return p;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment