Advertisement
Guest User

C++ Rubik Cube order calculator

a guest
May 23rd, 2013
1,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 19.04 KB | None | 0 0
  1. /*           DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  2.  *                   Version 2, December 2004
  3.  *
  4.  *         Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
  5.  *
  6.  *      Work may-2013 piou http://whitehathacking.wordpress.com
  7.  *
  8.  *  Everyone is permitted to copy and distribute verbatim or modified
  9.  *  copies of this license document, and changing it is allowed as long
  10.  *  as the name is changed.
  11.  *
  12.  *           DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  13.  *  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  14.  *
  15.  *  0. You just DO WHAT THE FUCK YOU WANT TO.
  16.  *  1. Just don't be an asshole and pretend you've done this (don't steal).
  17.  *  3. No fucking warranties bitches.
  18. */
  19. #include <iostream>
  20. #include <string>
  21. #include <fstream>
  22. #include <vector>
  23.  
  24. using namespace std;
  25.  
  26. enum COLOR {BLANCO,AZUL,AMARILLO,VERDE,NARANJA,ROJO};
  27.  
  28. bool check(COLOR U[][3],COLOR F[][3],COLOR D[][3],COLOR B[][3],COLOR R[][3],COLOR L[][3]);
  29.  
  30. void apply(COLOR U[][3],COLOR F[][3],COLOR D[][3],COLOR B[][3],COLOR R[][3],COLOR L[][3], string move);
  31.  
  32. void oneMove(COLOR U[][3],COLOR F[][3],COLOR D[][3],COLOR B[][3],COLOR R[][3],COLOR L[][3], char move);
  33.  
  34. void oneMovei(COLOR U[][3],COLOR F[][3],COLOR D[][3],COLOR B[][3],COLOR R[][3],COLOR L[][3], char move);
  35.  
  36. void showCube(COLOR U[][3],COLOR F[][3],COLOR D[][3],COLOR B[][3],COLOR R[][3],COLOR L[][3]);
  37.  
  38. int main() {
  39.     string movement;
  40.     char fileIn[40];
  41.     char fileOut[40];
  42.     int contador=0;
  43.     int opt,opt2;
  44.     fstream arIn;
  45.     fstream arOut;
  46.     COLOR U[3][3],F[3][3],D[3][3],B[3][3],R[3][3],L[3][3];
  47.     for (int i=0;i<3;i++) {
  48.         for (int j=0;j<3;j++) {
  49.             U[i][j]=BLANCO;
  50.             F[i][j]=AZUL;
  51.             D[i][j]=AMARILLO;
  52.             B[i][j]=VERDE;
  53.             R[i][j]=NARANJA;
  54.             L[i][j]=ROJO;
  55.         }
  56.     }
  57.  
  58.     while (1) {
  59.         cout << endl << endl;
  60.         cout << "Calculadora ordenes de subgrupos ciclicos del Cubo de Rubik (3x3x3):" << endl;
  61.         cout << endl << "1.- Introducir movimiento por teclado" << endl;
  62.         cout << "2.- Introducir movimiento por archivo" << endl;
  63.         cout << "n.- Salir" << endl << endl;
  64.         cin >> opt;
  65.         if (opt == 1) {
  66.             cout << "Notacion: " << endl;
  67.             cout << "Rotaciones de 90º en el sentido de las agujas del reloj:" << endl;
  68.             cout << "U: arriba" << endl << "F: frontal" << endl << "D: abajo" << endl << "B: atras" << endl << "R: derecha" << endl << "L: izquierda" << endl;
  69.             cout << "Xi: movimiento contrario a las agujas del reloj: XXX=Xi" << endl;
  70.             cout << "S para salir" << endl;
  71.             cout << endl << endl;
  72.             while (1) {
  73.                 contador=0;
  74.                 cin >> movement;
  75.                 if (movement[0] == 'S' || movement[0] == 's')
  76.                     break;
  77.                 do {
  78.                     contador++;
  79.                     apply(U,F,D,B,R,L,movement);
  80.                     //showCube(U,F,D,B,R,L);
  81.                 } while (!check(U,F,D,B,R,L));
  82.  
  83.                 cout << "Orden: " << contador << endl;
  84.             }
  85.         }
  86.         if (opt == 2) {
  87.             cout << "Notacion: " << endl;
  88.             cout << "Rotaciones de 90º en el sentido de las agujas del reloj:" << endl;
  89.             cout << "U: arriba" << endl << "F: frontal" << endl << "D: abajo" << endl << "B: atras" << endl << "R: derecha" << endl << "L: izquierda" << endl;
  90.             cout << "Xi: movimiento contrario a las agujas del reloj: XXX=Xi" << endl;
  91.             cout << endl << "El archivo debe tener movimientos separados por lineas" << endl;
  92.             cout << endl << endl;
  93.             cin >> fileIn;
  94.             arIn.open(fileIn);
  95.             if (!arIn) {
  96.                 cout << "El archivo no se puede abrir" << endl;
  97.                 break;
  98.             }
  99.             cout << "Guardar resultados en archivo (1), o mostrar por pantalla (2): " << endl;
  100.             cin >> opt2;
  101.             if (opt2 == 1) {
  102.                 cout << "Nombre del archivo: ";
  103.                 cin >> fileOut;
  104.                 arOut.open(fileOut,ios::out);
  105.             }
  106.             vector<string> movements;
  107.             string movExt;
  108.             while (getline(arIn,movExt)) {
  109.                 movements.push_back(movExt);
  110.             }
  111.             cout << "WOW: " << movements.size() << endl;
  112.             for (int i=0;i<movements.size();i++) {
  113.                 contador=0;
  114.                 do {
  115.                     contador++;
  116.                     apply(U,F,D,B,R,L,movements[i]);
  117.                 } while (!check(U,F,D,B,R,L));
  118.                 if (opt2 == 1) {
  119.                     arOut << contador << endl;
  120.                 }
  121.                 else {
  122.                     cout << contador << endl;
  123.                 }
  124.             }
  125.             if (opt2 == 1) {
  126.                 arOut.close();
  127.             }
  128.             arIn.close();
  129.         }
  130.         else
  131.             break;
  132.     }
  133.  
  134.     return 0;
  135. }
  136.  
  137. void showCube(COLOR U[][3],COLOR F[][3],COLOR D[][3],COLOR B[][3],COLOR R[][3],COLOR L[][3]) {
  138.     cout << "   " << U[0][0] << U[0][1] << U[0][2] << endl;
  139.     cout << "   " << U[1][0] << U[1][1] << U[1][2] << endl;
  140.     cout << "   " << U[2][0] << U[2][1] << U[2][2] << endl;
  141.     cout << L[0][0] << L[0][1] << L[0][2] << F[0][0] << F[0][1] << F[0][2] << R[0][0] << R[0][1] << R[0][2] << B[0][0] << B[0][1] << B[0][2] << endl;
  142.     cout << L[1][0] << L[1][1] << L[1][2] << F[1][0] << F[1][1] << F[1][2] << R[1][0] << R[1][1] << R[1][2] << B[1][0] << B[1][1] << B[1][2] << endl;
  143.     cout << L[2][0] << L[2][1] << L[2][2] << F[2][0] << F[2][1] << F[2][2] << R[2][0] << R[2][1] << R[2][2] << B[2][0] << B[2][1] << B[2][2] << endl;
  144.     cout << "   " << D[0][0] << D[0][1] << D[0][2] << endl;
  145.     cout << "   " << D[1][0] << D[1][1] << D[1][2] << endl;
  146.     cout << "   " << D[2][0] << D[2][1] << D[2][2] << endl;
  147. }
  148.  
  149. bool check(COLOR U[][3],COLOR F[][3],COLOR D[][3],COLOR B[][3],COLOR R[][3],COLOR L[][3]) {
  150.     for (int i=0;i<3;i++) {
  151.         for (int j=0;j<3;j++) {
  152.             if (U[i][j]!=BLANCO)
  153.                 return false;
  154.             if (F[i][j]!=AZUL)
  155.                 return false;
  156.             if (D[i][j]!=AMARILLO)
  157.                 return false;
  158.             if (B[i][j]!=VERDE)
  159.                 return false;
  160.             if (R[i][j]!=NARANJA)
  161.                 return false;
  162.             if (L[i][j]!=ROJO)
  163.                 return false;
  164.         }
  165.     }
  166.     return true;
  167. }
  168.  
  169. void apply(COLOR U[][3],COLOR F[][3],COLOR D[][3],COLOR B[][3],COLOR R[][3],COLOR L[][3], string move) {
  170.     int length = move.size();
  171.     for (int k=0;k<length;k++) {
  172.         if (k!=length-1) {
  173.             if (move[k+1]=='i') {
  174.                 oneMovei(U,F,D,B,R,L,move[k]);
  175.                 k++;
  176.             }
  177.             else {
  178.                 oneMove(U,F,D,B,R,L,move[k]);
  179.             }
  180.         }
  181.         else
  182.             oneMove(U,F,D,B,R,L,move[k]);
  183.     }
  184. }
  185.  
  186. void oneMove(COLOR U[][3],COLOR F[][3],COLOR D[][3],COLOR B[][3],COLOR R[][3],COLOR L[][3], char move) {
  187.     switch (move) {
  188.         case 'U':
  189.         {
  190.             COLOR auxU[3][3];
  191.             for (int i=0;i<3;i++) {
  192.                 for (int j=0;j<3;j++) {
  193.                     auxU[i][j]=U[i][j];
  194.                 }
  195.             }
  196.             COLOR auxF[3] = {F[0][0],F[0][1],F[0][2]};
  197.             COLOR auxR[3] = {R[0][0],R[0][1],R[0][2]};
  198.             COLOR auxB[3] = {B[0][0],B[0][1],B[0][2]};
  199.             COLOR auxL[3] = {L[0][0],L[0][1],L[0][2]};
  200.             //Asignaciones:
  201.             U[0][0] = auxU[2][0]; U[0][1] = auxU[1][0]; U[0][2] = auxU[0][0];
  202.             U[1][0] = auxU[2][1];                       U[1][2] = auxU[0][1];
  203.             U[2][0] = auxU[2][2]; U[2][1] = auxU[1][2]; U[2][2] = auxU[0][2];
  204.             F[0][0] = auxR[0]; F[0][1] = auxR[1]; F[0][2] = auxR[2];
  205.             R[0][0] = auxB[0]; R[0][1] = auxB[1]; R[0][2] = auxB[2];
  206.             B[0][0] = auxL[0]; B[0][1] = auxL[1]; B[0][2] = auxL[2];
  207.             L[0][0] = auxF[0]; L[0][1] = auxF[1]; L[0][2] = auxF[2];
  208.             break;
  209.         }
  210.  
  211.         case 'F':
  212.         {
  213.             COLOR auxF[3][3];
  214.             for (int i=0;i<3;i++) {
  215.                 for (int j=0;j<3;j++) {
  216.                     auxF[i][j]=F[i][j];
  217.                 }
  218.             }
  219.             COLOR auxU[3] = {U[2][0],U[2][1],U[2][2]};
  220.             COLOR auxR[3] = {R[0][0],R[1][0],R[2][0]};
  221.             COLOR auxD[3] = {D[0][0],D[0][1],D[0][2]};
  222.             COLOR auxL[3] = {L[0][2],L[1][2],L[2][2]};
  223.             //Asignaciones:
  224.             F[0][0] = auxF[2][0]; F[0][1] = auxF[1][0]; F[0][2] = auxF[0][0];
  225.             F[1][0] = auxF[2][1];                       F[1][2] = auxF[0][1];
  226.             F[2][0] = auxF[2][2]; F[2][1] = auxF[1][2]; F[2][2] = auxF[0][2];
  227.             U[2][0] = auxL[2]; U[2][1] = auxL[1]; U[2][2] = auxL[0];
  228.             L[0][2] = auxD[0]; L[1][2] = auxD[1]; L[2][2] = auxD[2];
  229.             D[0][0] = auxR[2]; D[0][1] = auxR[1]; D[0][2] = auxR[0];
  230.             R[0][0] = auxU[0]; R[1][0] = auxU[1]; R[2][0] = auxU[2];
  231.             break;
  232.         }
  233.  
  234.         case 'D':
  235.         {
  236.             COLOR auxD[3][3];
  237.             for (int i=0;i<3;i++) {
  238.                 for (int j=0;j<3;j++) {
  239.                     auxD[i][j]=D[i][j];
  240.                 }
  241.             }
  242.             COLOR auxF[3] = {F[2][0],F[2][1],F[2][2]};
  243.             COLOR auxR[3] = {R[2][0],R[2][1],R[2][2]};
  244.             COLOR auxB[3] = {B[2][0],B[2][1],B[2][2]};
  245.             COLOR auxL[3] = {L[2][0],L[2][1],L[2][2]};
  246.             //Asignaciones:
  247.             D[0][0] = auxD[2][0]; D[0][1] = auxD[1][0]; D[0][2] = auxD[0][0];
  248.             D[1][0] = auxD[2][1];                       D[1][2] = auxD[0][1];
  249.             D[2][0] = auxD[2][2]; D[2][1] = auxD[1][2]; D[2][2] = auxD[0][2];
  250.             F[2][0] = auxL[0]; F[2][1] = auxL[1]; F[2][2] = auxL[2];
  251.             L[2][0] = auxB[0]; L[2][1] = auxB[1]; L[2][2] = auxB[2];
  252.             B[2][0] = auxR[0]; B[2][1] = auxR[1]; B[2][2] = auxR[2];
  253.             R[2][0] = auxF[0]; R[2][1] = auxF[1]; R[2][2] = auxF[2];
  254.             break;
  255.         }
  256.  
  257.         case 'B':
  258.         {
  259.             COLOR auxB[3][3];
  260.             for (int i=0;i<3;i++) {
  261.                 for (int j=0;j<3;j++) {
  262.                     auxB[i][j]=B[i][j];
  263.                 }
  264.             }
  265.             COLOR auxU[3] = {U[0][0],U[0][1],U[0][2]};
  266.             COLOR auxR[3] = {R[0][2],R[1][2],R[2][2]};
  267.             COLOR auxD[3] = {D[2][0],D[2][1],D[2][2]};
  268.             COLOR auxL[3] = {L[0][0],L[1][0],L[2][0]};
  269.             //Asignaciones:
  270.             B[0][0] = auxB[2][0]; B[0][1] = auxB[1][0]; B[0][2] = auxB[0][0];
  271.             B[1][0] = auxB[2][1];                       B[1][2] = auxB[0][1];
  272.             B[2][0] = auxB[2][2]; B[2][1] = auxB[1][2]; B[2][2] = auxB[0][2];
  273.             U[0][0] = auxR[0]; U[0][1] = auxR[1]; U[0][2] = auxR[2];
  274.             R[0][2] = auxD[2]; R[1][2] = auxD[1]; R[2][2] = auxD[0];
  275.             D[2][0] = auxL[0]; D[2][1] = auxL[1]; D[2][2] = auxL[2];
  276.             L[0][0] = auxU[2]; L[1][0] = auxU[1]; L[2][0] = auxU[0];
  277.             break;
  278.         }
  279.  
  280.         case 'R':
  281.         {
  282.             COLOR auxR[3][3];
  283.             for (int i=0;i<3;i++) {
  284.                 for (int j=0;j<3;j++) {
  285.                     auxR[i][j]=R[i][j];
  286.                 }
  287.             }
  288.             COLOR auxU[3] = {U[0][2],U[1][2],U[2][2]};
  289.             COLOR auxB[3] = {B[0][0],B[1][0],B[2][0]};
  290.             COLOR auxD[3] = {D[0][2],D[1][2],D[2][2]};
  291.             COLOR auxF[3] = {F[0][2],F[1][2],F[2][2]};
  292.             //Asignaciones:
  293.             R[0][0] = auxR[2][0]; R[0][1] = auxR[1][0]; R[0][2] = auxR[0][0];
  294.             R[1][0] = auxR[2][1];                       R[1][2] = auxR[0][1];
  295.             R[2][0] = auxR[2][2]; R[2][1] = auxR[1][2]; R[2][2] = auxR[0][2];
  296.             U[0][2] = auxF[0]; U[1][2] = auxF[1]; U[2][2] = auxF[2];
  297.             F[0][2] = auxD[0]; F[1][2] = auxD[1]; F[2][2] = auxD[2];
  298.             D[0][2] = auxB[2]; D[1][2] = auxB[1]; D[2][2] = auxB[0];
  299.             B[0][0] = auxU[2]; B[1][0] = auxU[1]; B[2][0] = auxU[0];
  300.             break;
  301.         }
  302.  
  303.         case 'L':
  304.         {
  305.             COLOR auxL[3][3];
  306.             for (int i=0;i<3;i++) {
  307.                 for (int j=0;j<3;j++) {
  308.                     auxL[i][j]=L[i][j];
  309.                 }
  310.             }
  311.             COLOR auxU[3] = {U[0][0],U[1][0],U[2][0]};
  312.             COLOR auxB[3] = {B[0][2],B[1][2],B[2][2]};
  313.             COLOR auxD[3] = {D[0][0],D[1][0],D[2][0]};
  314.             COLOR auxF[3] = {F[0][0],F[1][0],F[2][0]};
  315.             //Asignaciones:
  316.             L[0][0] = auxL[2][0]; L[0][1] = auxL[1][0]; L[0][2] = auxL[0][0];
  317.             L[1][0] = auxL[2][1];                       L[1][2] = auxL[0][1];
  318.             L[2][0] = auxL[2][2]; L[2][1] = auxL[1][2]; L[2][2] = auxL[0][2];
  319.             U[0][0] = auxB[2]; U[1][0] = auxB[1]; U[2][0] = auxB[0];
  320.             F[0][0] = auxU[0]; F[1][0] = auxU[1]; F[2][0] = auxU[2];
  321.             D[0][0] = auxF[0]; D[1][0] = auxF[1]; D[2][0] = auxF[2];
  322.             B[0][2] = auxD[2]; B[1][2] = auxD[1]; B[2][2] = auxD[0];
  323.             break;
  324.         }
  325.     }
  326. }
  327.  
  328. void oneMovei(COLOR U[][3],COLOR F[][3],COLOR D[][3],COLOR B[][3],COLOR R[][3],COLOR L[][3], char move) {
  329.     switch (move) {
  330.         case 'U':
  331.         {
  332.             COLOR auxU[3][3];
  333.             for (int i=0;i<3;i++) {
  334.                 for (int j=0;j<3;j++) {
  335.                     auxU[i][j]=U[i][j];
  336.                 }
  337.             }
  338.             COLOR auxF[3] = {F[0][0],F[0][1],F[0][2]};
  339.             COLOR auxR[3] = {R[0][0],R[0][1],R[0][2]};
  340.             COLOR auxB[3] = {B[0][0],B[0][1],B[0][2]};
  341.             COLOR auxL[3] = {L[0][0],L[0][1],L[0][2]};
  342.             //Asignaciones:
  343.             U[2][0] = auxU[0][0]; U[1][0] = auxU[0][1]; U[0][0] = auxU[0][2];
  344.             U[2][1] = auxU[1][0];                       U[0][1] = auxU[1][2];
  345.             U[2][2] = auxU[2][0]; U[1][2] = auxU[2][1]; U[0][2] = auxU[2][2];
  346.             F[0][0] = auxL[0]; F[0][1] = auxL[1]; F[0][2] = auxL[2];
  347.             R[0][0] = auxF[0]; R[0][1] = auxF[1]; R[0][2] = auxF[2];
  348.             B[0][0] = auxR[0]; B[0][1] = auxR[1]; B[0][2] = auxR[2];
  349.             L[0][0] = auxB[0]; L[0][1] = auxB[1]; L[0][2] = auxB[2];
  350.             break;
  351.         }
  352.  
  353.         case 'F':
  354.         {
  355.             COLOR auxF[3][3];
  356.             for (int i=0;i<3;i++) {
  357.                 for (int j=0;j<3;j++) {
  358.                     auxF[i][j]=F[i][j];
  359.                 }
  360.             }
  361.             COLOR auxU[3] = {U[2][0],U[2][1],U[2][2]};
  362.             COLOR auxR[3] = {R[0][0],R[1][0],R[2][0]};
  363.             COLOR auxD[3] = {D[0][0],D[0][1],D[0][2]};
  364.             COLOR auxL[3] = {L[0][2],L[1][2],L[2][2]};
  365.             //Asignaciones:
  366.             F[2][0] = auxF[0][0]; F[1][0] = auxF[0][1]; F[0][0] = auxF[0][2];
  367.             F[2][1] = auxF[1][0];                       F[0][1] = auxF[1][2];
  368.             F[2][2] = auxF[2][0]; F[1][2] = auxF[2][1]; F[0][2] = auxF[2][2];
  369.             U[2][0] = auxR[0]; U[2][1] = auxR[1]; U[2][2] = auxR[2];
  370.             L[0][2] = auxU[2]; L[1][2] = auxU[1]; L[2][2] = auxU[0];
  371.             D[0][0] = auxL[0]; D[0][1] = auxL[1]; D[0][2] = auxL[2];
  372.             R[0][0] = auxD[2]; R[1][0] = auxD[1]; R[2][0] = auxD[0];
  373.             break;
  374.         }
  375.  
  376.         case 'D':
  377.         {
  378.             COLOR auxD[3][3];
  379.             for (int i=0;i<3;i++) {
  380.                 for (int j=0;j<3;j++) {
  381.                     auxD[i][j]=D[i][j];
  382.                 }
  383.             }
  384.             COLOR auxF[3] = {F[2][0],F[2][1],F[2][2]};
  385.             COLOR auxR[3] = {R[2][0],R[2][1],R[2][2]};
  386.             COLOR auxB[3] = {B[2][0],B[2][1],B[2][2]};
  387.             COLOR auxL[3] = {L[2][0],L[2][1],L[2][2]};
  388.             //Asignaciones:
  389.             D[2][0] = auxD[0][0]; D[1][0] = auxD[0][1]; D[0][0] = auxD[0][2];
  390.             D[2][1] = auxD[1][0];                       D[0][1] = auxD[1][2];
  391.             D[2][2] = auxD[2][0]; D[1][2] = auxD[2][1]; D[0][2] = auxD[2][2];
  392.             F[2][0] = auxR[0]; F[2][1] = auxR[1]; F[2][2] = auxR[2];
  393.             L[2][0] = auxF[0]; L[2][1] = auxF[1]; L[2][2] = auxF[2];
  394.             B[2][0] = auxL[0]; B[2][1] = auxL[1]; B[2][2] = auxL[2];
  395.             R[2][0] = auxB[0]; R[2][1] = auxB[1]; R[2][2] = auxB[2];
  396.             break;
  397.         }
  398.  
  399.         case 'B':
  400.         {
  401.             COLOR auxB[3][3];
  402.             for (int i=0;i<3;i++) {
  403.                 for (int j=0;j<3;j++) {
  404.                     auxB[i][j]=B[i][j];
  405.                 }
  406.             }
  407.             COLOR auxU[3] = {U[0][0],U[0][1],U[0][2]};
  408.             COLOR auxR[3] = {R[0][2],R[1][2],R[2][2]};
  409.             COLOR auxD[3] = {D[2][0],D[2][1],D[2][2]};
  410.             COLOR auxL[3] = {L[0][0],L[1][0],L[2][0]};
  411.             //Asignaciones:
  412.             B[2][0] = auxB[0][0]; B[1][0] = auxB[0][1]; B[0][0] = auxB[0][2];
  413.             B[2][1] = auxB[1][0];                       B[0][1] = auxB[1][2];
  414.             B[2][2] = auxB[2][0]; B[1][2] = auxB[2][1]; B[0][2] = auxB[2][2];
  415.             U[0][0] = auxL[2]; U[0][1] = auxL[1]; U[0][2] = auxL[0];
  416.             R[0][2] = auxU[0]; R[1][2] = auxU[1]; R[2][2] = auxU[2];
  417.             D[2][0] = auxR[2]; D[2][1] = auxR[1]; D[2][2] = auxR[0];
  418.             L[0][0] = auxD[0]; L[1][0] = auxD[1]; L[2][0] = auxD[2];
  419.             break;
  420.         }
  421.  
  422.         case 'R':
  423.         {
  424.             COLOR auxR[3][3];
  425.             for (int i=0;i<3;i++) {
  426.                 for (int j=0;j<3;j++) {
  427.                     auxR[i][j]=R[i][j];
  428.                 }
  429.             }
  430.             COLOR auxU[3] = {U[0][2],U[1][2],U[2][2]};
  431.             COLOR auxB[3] = {B[0][0],B[1][0],B[2][0]};
  432.             COLOR auxD[3] = {D[0][2],D[1][2],D[2][2]};
  433.             COLOR auxF[3] = {F[0][2],F[1][2],F[2][2]};
  434.             //Asignaciones:
  435.             R[2][0] = auxR[0][0]; R[1][0] = auxR[0][1]; R[0][0] = auxR[0][2];
  436.             R[2][1] = auxR[1][0];                       R[0][1] = auxR[1][2];
  437.             R[2][2] = auxR[2][0]; R[1][2] = auxR[2][1]; R[0][2] = auxR[2][2];
  438.             U[0][2] = auxB[2]; U[1][2] = auxB[1]; U[2][2] = auxB[0];
  439.             F[0][2] = auxU[0]; F[1][2] = auxU[1]; F[2][2] = auxU[2];
  440.             D[0][2] = auxF[0]; D[1][2] = auxF[1]; D[2][2] = auxF[2];
  441.             B[0][0] = auxD[2]; B[1][0] = auxD[1]; B[2][0] = auxD[0];
  442.             break;
  443.         }
  444.  
  445.         case 'L':
  446.         {
  447.             COLOR auxL[3][3];
  448.             for (int i=0;i<3;i++) {
  449.                 for (int j=0;j<3;j++) {
  450.                     auxL[i][j]=L[i][j];
  451.                 }
  452.             }
  453.             COLOR auxU[3] = {U[0][0],U[1][0],U[2][0]};
  454.             COLOR auxB[3] = {B[0][2],B[1][2],B[2][2]};
  455.             COLOR auxD[3] = {D[0][0],D[1][0],D[2][0]};
  456.             COLOR auxF[3] = {F[0][0],F[1][0],F[2][0]};
  457.             //Asignaciones:
  458.             L[2][0] = auxL[0][0]; L[1][0] = auxL[0][1]; L[0][0] = auxL[0][2];
  459.             L[2][1] = auxL[1][0];                       L[0][1] = auxL[1][2];
  460.             L[2][2] = auxL[2][0]; L[1][2] = auxL[2][1]; L[0][2] = auxL[2][2];
  461.             U[0][0] = auxF[0]; U[1][0] = auxF[1]; U[2][0] = auxF[2];
  462.             F[0][0] = auxD[0]; F[1][0] = auxD[1]; F[2][0] = auxD[2];
  463.             D[0][0] = auxB[2]; D[1][0] = auxB[1]; D[2][0] = auxB[0];
  464.             B[0][2] = auxU[2]; B[1][2] = auxU[1]; B[2][2] = auxU[0];
  465.             break;
  466.         }
  467.     }
  468. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement