思路
分类讨论:
- 统计字符串的长度, 直接输出字符串;
- 否则输出字符串的头, 和字符串的尾;
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n;
cin >> n;
while (n --) {
string str;
cin >> str;
int len = str.size();
if (len < 10) {
cout << str << endl;
} else {
cout << str.front() << len - 2 << str.back() << endl;
}
}
return 0;
}

京公网安备 11010502036488号