编程练习

codeforces 71A (string)

2017-03-30  本文已影响0人  codinRay

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;
}
上一篇 下一篇

猜你喜欢

热点阅读