You are viewing a single comment's thread. Return to all comments →
easy to understand solution in C++ for beginners
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <map> using namespace std; int N = 1e4; int main() { vector<char> arr; char* str = new char[N]; cin.getline(str, N); int i = 0; while (str[i] != '\0') { arr.push_back(str[i]); i++; } delete[] str; string result; vector<string> st = {"Hello,", "World."}; for (size_t i = 0; i < st.size(); ++i) { result += st[i]; if (i < st.size() - 1) { result += " "; } } cout << result << endl; map<int, char> myMap; for (int i = 0; i < arr.size(); ++i) { myMap.insert({i, arr[i]}); } for (auto& entry : myMap) { cout << entry.second; } cout << endl; return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 0: Hello, World.
You are viewing a single comment's thread. Return to all comments →