Calculate the distance between two keys.(计算两个按键之间的距离。)
Project URL:(项目地址:) https://github.com/LetMeFly666/KeyboardDistance
Online Address: (在线地址:) https://keyboarddistance.letmefly.xyz
The keyboard looks like:(键盘形状如下:)
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │
└┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┘
│ A │ S │ D │ F │ G │ H │ J │ K │ L │
└─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┘
│ Z │ X │ C │ V │ B │ N │ M │
└───┴───┴───┴───┴───┴───┴───┘
We define that the minimum distance of two key which have the same border is 2.(我们定义:具有公共边的两个按键的最短距离为1)
For example, The keys with the shortest distance of 2 from F are R, T, G, V, C, and D.(例如,和F最短距离为2的按键有R、T、G、V、C和D)
Use the keyboarddistance class in main.cpp directly.(直接使用main.cpp里的KeyboardDistance类即可。)
KeyboardDistance kd;
char a, b;
while (cin >> a >> b) {
cout << kd.getDistance(a, b) << endl;
}