Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Trello, Principiante, 2008n1p1-descubriendo-el-refran
- #include <iostream> ///Antonelli Alen Gabriel
- #include <vector>
- using namespace std;
- int main ()
- {
- int p=0;
- string aux, aux1, aux2, aux3;
- cin >> p;
- vector <string> v (p, ".");
- for (int i=0; i<p; i++)
- {
- cin >> aux;
- v[i]=aux;
- }
- for (int i=0; i<p; i++)
- {
- aux="";
- aux=v[i];
- if (aux.size()%2==0) // invertir
- {
- for (int j=0; j<aux.size(); j++)
- {
- v[i][j]=aux[aux.size()-j-1];
- }
- }
- if (aux.size()%2==1)
- {
- if (aux.size()!=1 && aux.size()!=3) // intercambiar extremos dejando las tres de el medio iguales
- {
- aux1="";
- aux2="";
- aux3="";
- for (int j=0; j<aux.size(); j++) /// pu nte ro (7) - 3 = 4 / 2 = 2
- { /// 01 234 56
- if (j<((aux.size()-3)/2))
- aux1.push_back(aux[j]);
- if ( ((aux.size()-3)/2)<=j && j<((aux.size()-3)/2)+3 )
- aux2.push_back(aux[j]);
- if (j>=((aux.size()-3)/2)+3)
- aux3.push_back(aux[j]);
- }
- v[i]=aux3+aux2+aux1;
- }
- }
- }
- for (int i=0; i<p; i++)
- {
- cout << v[i];
- if (i<p-1)
- cout<< " ";
- }
- cout<<".";
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment