#include <string>
#include <algorithm>
#include <iostream>
int main()
{
string str;
string str1;
int h = 0;
cin >> str;
if (str.length() > 10)
{
str1 += str.front();
h = str.length() - 2;
string s = to_string(h);
str1 += s;
str1 += str.back();
cout << str1;
}
else cout << str;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译在XCode中,但不在codeforces.ru/上
?an't compile program.cpp:
program.cpp: In function 'int main()':
program.cpp:23:21: error: 'std::string' has no member named 'front'
program.cpp:27:29: error: 'to_string' was not declared in this scope …Run Code Online (Sandbox Code Playgroud) 我刚刚将Xcode 7更新为beta5,并发现split函数已被split方法替换.我对Swift没有经验,但还没弄明白如何将我当前的代码更新为新语法.
let components = split(name.characters){$0 == "."}.map { String($0) }
// 'split(_:maxSplit:allowEmptySlices:isSeparator:)' is unavailable: Use the split() method instead.
Run Code Online (Sandbox Code Playgroud)