Codeforces 71.A

A. Way Too Long Words

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.

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".

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\leq n\leq 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.

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

Examples:

input

	4
	word
	localization
	internationalization
	pneumonoultramicroscopicsilicovolcanoconiosis

output

	word
	l10n
	i18n
	p43s

题目解读:

? 意思就是如果字符串的长度超过10,就要进行压缩,压缩方法见Examples,十分易懂。

AC代码

#include <iostream>
#include <cstring>

using namespace std;

const int MAXN = 101;
char str[MAXN];
int main() {
    int n;
    cin >> n;
    for (int i=1;i<=n;i++) {
        cin >> str;
        if (strlen(str)>10) cout << str[0] << strlen(str)-2 << str[strlen(str)-1] << endl;
        else cout << str << endl;;
    }
    return 0;
}

Codeforces 71.A

上一篇:【任务脚本】更新淘宝京东任务脚本,jd年兽任务脚本,京东淘宝活动任务全自动程序...


下一篇:pig4cloud中feign使用案例