Algorithm

[CodeForce] 71A - Way Too Long Words

승우승 2019. 1. 25. 09:06
반응형

처음으로 코드포스 문제를 풀어봤다. 영어로 문제가 되있으니 처음에 엄청 쫄았는데 간단했다. 코드포스와 백준을 이제 같이 풀어나가야겠다. 단순 string을 조작하는 간단한 문제입니다.


소스코드


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>
// http://codeforces.com/problemset/problem/71/A
using namespace std;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int tc;
    cin>>tc;
    string str;
    while(tc--) {
        cin>>str;
        if(str.length()>10cout<<str[0]<<str.length()-2<<str[str.length()-1]<<endl;
        else    cout<<str<<endl;
    }
    return 0;
}
cs


반응형