Created
August 30, 2016 10:46
-
-
Save evilmucedin/de78731a8096236f4198ca0de1981577 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
static string InjectSpaces(const string& s) { | |
string result(2*s.length() - 1, ' '); | |
char* pResult = (char*)result.data(); | |
const char* pS = s.data(); | |
const auto length = s.length(); | |
for (auto i = 0; i < length; ++i) { | |
pResult[2*i] = pS[i]; | |
} | |
return result; | |
} | |
int main() { | |
string s = "1234567890"; | |
string result; | |
for (size_t i = 0; i < 200000000; ++i) { | |
result = InjectSpaces(s); | |
} | |
cout << result << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment