Guest User

Rubiks C++ code

a guest
Dec 4th, 2016
73
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2.  
  3. using namespace std;
  4. // filling the faces of cube
  5. void fill (char *a, char b) {
  6. for (int i = 0; i<3; i++){
  7. for (int j = 0; j<3; j++){
  8. a[i][j] = b;
  9. }
  10. }
  11. }
  12. // performing moves on a cube
  13. // by interchanging the pieces
  14. void interchange (char &a, char &b, char &c, char &d) {
  15. char e, f, g;
  16. e = b;
  17. f = c;
  18. g = d;
  19. b = a;
  20. c = e;
  21. d = f;
  22. a = g;
  23. }
  24. int main () {
  25. //6 faces of rubik's cube
  26. char f[3][3];
  27. char b[3][3];
  28. char r[3][3];
  29. char l[3][3];
  30. char u[3][3];
  31. char d[3][3];
  32. //filling the faces
  33. fill(f, 'W');
  34. fill(b, 'Y');
  35. fill(r, 'O');
  36. fill(l, 'R');
  37. fill(u, 'G');
  38. fill(d, 'B');
  39. /* Testing of interchange function*/
  40. char x, y, z, p;
  41. cin >> x >> y >> z >> p;
  42. interchange(x,y,z,p);
  43. cout << x << " " << y << " " << z << " " << p << " " << endl;
  44. }
RAW Paste Data