71A. Way Too Long Words

71A. Way Too Long Words

  • time limit per test1 second
  • memory limit per test256 megabytes
  • inputstandard input
  • outputstandard output

Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.

有时,像“本地化”或“国际化”这样的词太长,以至于在一篇文章中多次书写它们是相当令人厌烦的。

Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.

让我们考虑一个词太长,如果它的长度严格超过10个字符。所有太长的单词都应该用一个特殊的缩写替换。

This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes.

这个缩写是这样写的:我们写下一个单词的第一个和最后一个字母,在它们之间我们写下第一个和最后一个字母之间的字母数。这个数字是十进制的,不包含任何前导零。

Thus, "localization" will be spelt as "l10n", and "internationalization» will be spelt as "i18n".

因此,“本地化”将拼写为“l10n”,而“国际化”将拼写为“i18n”。

You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes.

建议你用缩略语自动更改单词的过程。此时,太长的单词应该被缩写替换,不太长的单词不应该进行任何更改。

Input

The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.

第一行包含一个整数n(1) ≤ N ≤ 100). 以下n行中的每一行都包含一个单词。所有单词都由小写拉丁字母组成,长度为1到100个字符。

Output

Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.

打印n行。第i行应该包含从输入数据中替换第i个字的结果。

Examples
input

4 word localization internationalization pneumonoultramicroscopicsilicovolcanoconiosis

output

word l10n i18n p43s

Solution

分类讨论,如果单词长度>10,输出单词首位+(单词长度-2)+单词末位 如果单词长度<=10,输出单词

Code
#include <iostream>
using namespace std;

//71A. Way Too Long Words
int main() {
    int n = 0;//n:以下n行
    cin >> n;
    for(int i = 0;i < n;i++){
        string word;//word:单词
        cin >> word;
        int len = word.size();
        if(len<=10){//词太长,如果它的长度严格超过10个字符
            cout << word << endl;
        }else{
            cout << word[0] << len-2 << word[len-1] << endl;
        }
    }
    return 0;
}