美文网首页编程练习
codeforces 71A (string)

codeforces 71A (string)

作者: codinRay | 来源:发表于2017-03-30 21:13 被阅读0次

http://codeforces.com/problemset/problem/71/A

生词:
abbreviation n.缩写

题面:
每个string,如果length超过10就输出第一个字符,length-2,最后一个字符。否则原样输出。

// codeforces
// 71A 
// string
#include <iostream>
#include <string>
using namespace std;
int main() {
    int N;
    cin >> N;
    string s;
    while (N--) {
        cin >> s;
        int len = (int)s.length();
        if (len <= 10) {
            cout << s << '\n';
            continue;
        }
        cout << *s.begin() << len - 2 << *(s.end() - 1) << '\n';
    }
    return 0;
}

相关文章

网友评论

    本文标题:codeforces 71A (string)

    本文链接:https://www.haomeiwen.com/subject/xjnpottx.html