An open API service indexing awesome lists of open source software.

https://github.com/letmefly666/keyboarddistance

Calculate the distance between two keys.
https://github.com/letmefly666/keyboarddistance

keyboard

Last synced: about 2 months ago
JSON representation

Calculate the distance between two keys.

Awesome Lists containing this project

README

          

# KeyboardDistance

Calculate the distance between two keys.(计算两个按键之间的距离。)

Project URL:(项目地址:) [https://github.com/LetMeFly666/KeyboardDistance](https://github.com/LetMeFly666/KeyboardDistance)

Online Address: (在线地址:) [https://keyboarddistance.letmefly.xyz](https://keyboarddistance.letmefly.xyz)

---

## Introduction(介绍)

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)

## Usage(用法)

Use the ```keyboarddistance``` class in ```main.cpp``` directly.(直接使用```main.cpp```里的```KeyboardDistance```类即可。)

```cpp
KeyboardDistance kd;
char a, b;
while (cin >> a >> b) {
cout << kd.getDistance(a, b) << endl;
}
```