【CodeForces】A. Way Too Long Words
2016-02-28 10:26
821 查看
Problem here: http: //codeforces.com/problemset/problem/71/A
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.
word
localization
internationalization
pneumonoultramicroscopicsilicovolcanoconiosis
l10n
i18n
p43s
if its length is strictly more than 10 characters.
Problem
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 ≤ 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.Output
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.Sample test(s)
input
4word
localization
internationalization
pneumonoultramicroscopicsilicovolcanoconiosis
output
wordl10n
i18n
p43s
Solution
注意这句if its length is strictly more than 10 characters.
#include <iostream> #include <string> using namespace std; int main(){ int n; while(cin >> n){ string input; while(n--){ cin >> input; if(input.length() > 10){ cout << input[0] << input.length()-2 << input[input.length()-1] << endl; }else{ cout << input << endl; } } } return 0; }
相关文章推荐
- Codeforces Round #197 (Div. 2)
- Codeforces Round #198 (Div. 1)
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces 407C Codeforces Round #239 (Div. 1)C
- CodeForces 449A - Jzzhu and Chocolate
- CodeForces 449 B. Jzzhu and Cities
- Codeforces Round #265 (Div. 2)
- Codeforces #310 div2 C. Case of Matryoshkas
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- codeforces 16 Problem E fish
- Codeforces Round332 部分题解
- CodeForces 603A_Alternative Thinking (DP)
- CodeForces 602B_Approximating a Constant Range_DP
- Codeforces round #247 for Div. 2
- Codeforces Round #246 (Div. 2)
- Codeforces #264(div 2)D.Gargari and Permutations
- Codeforces Round #236 (Div. 2)------A,B
- codeforces 257 div2 B
- Codeforces Gym100571A Cursed Query
- Codeforces Gym100342E Minima