/
TireRotation.cpp
56 lines (47 loc) · 1.73 KB
/
TireRotation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
class TireRotation {
public:
int getCycle(string initial, string current) {
string rot = initial, tmp;
int i, j, flagDifferent = 0;
for(i=1; i<=4; i++)
{
flagDifferent = 0;
for(j=0; j<4; j++)
if(rot[j] != current[j])
{
flagDifferent = 1;
break;
}
cout << i << ": " << rot[0] << rot[1] << rot[2] << rot[3] << endl;
if(flagDifferent == 0)
return i;
else
{
cout << i << ": " << rot[0] << rot[1] << rot[2] << rot[3] << endl;
tmp[2] = rot[0];
cout << i << ": " << rot[0] << rot[1] << rot[2] << rot[3] << endl;
tmp[3] = rot[1];
cout << i << ": " << rot[0] << rot[1] << rot[2] << rot[3] << endl;
tmp[1] = rot[2];
cout << i << ": " << rot[0] << rot[1] << rot[2] << rot[3] << endl;
tmp[0] = rot[3];
cout << tmp[0] << tmp[1] << tmp[2] << tmp[3] << endl;
rot = tmp;
printf("rot: %p, tmp: %p", &rot, &tmp);
//for(j=0; j<4; j++)
//rot[j] = tmp[j];
}
}
return -1;
}
};
// Powered by FileEdit
// Powered by TZTester 1.01 [25-Feb-2003]
// Powered by CodeProcessor