Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- // filling the faces of cube
- void fill (char *a, char b) {
- for (int i = 0; i<3; i++){
- for (int j = 0; j<3; j++){
- a[i][j] = b;
- }
- }
- }
- // performing moves on a cube
- // by interchanging the pieces
- void interchange (char &a, char &b, char &c, char &d) {
- char e, f, g;
- e = b;
- f = c;
- g = d;
- b = a;
- c = e;
- d = f;
- a = g;
- }
- int main () {
- //6 faces of rubik's cube
- char f[3][3];
- char b[3][3];
- char r[3][3];
- char l[3][3];
- char u[3][3];
- char d[3][3];
- //filling the faces
- fill(f, 'W');
- fill(b, 'Y');
- fill(r, 'O');
- fill(l, 'R');
- fill(u, 'G');
- fill(d, 'B');
- /* Testing of interchange function*/
- char x, y, z, p;
- cin >> x >> y >> z >> p;
- interchange(x,y,z,p);
- cout << x << " " << y << " " << z << " " << p << " " << endl;
- }
Add Comment
Please, Sign In to add comment