You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.1 KiB

2 years ago
#include <bits/stdc++.h>
using namespace std;
// 交换上下两行
string A(string t) {
// 1234 5678---> 8765 4321
// 使用瞪眼大法发现开始位置与终止位置是关于中线对称的即0<->7,1<->6,2<->5,3<->4,这样就简单了直接i<->7-i
for (int i = 0; i < 4; i++) swap(t[i], t[7 - i]);
return t;
}
// 将最右边的一列插入到最左边
string B(string t) {
// 1234 5678 ---> 4123 6785
// 4向上冒泡,5向后冒泡
for (int i = 3; i > 0; i--) swap(t[i], t[i - 1]);
for (int i = 4; i < 7; i++) swap(t[i], t[i + 1]);
return t;
}
// 魔板中央对的4个数作顺时针旋转
string C(string t) {
// 1234 5678 ---> 1724 5368
/*
swap(t[1], t[2]) 1234 5678 -> 1324 5678
swap(t[5], t[6]) 1324 5678 -> 1324 5768
swap(t[1], t[5]) 1324 5768 -> 1724 5368
*/
swap(t[1], t[2]), swap(t[5], t[6]), swap(t[1], t[5]);
return t;
}
int main() {
return 0;
}