Task: | Monistus |
Sender: | Bean Benestrom |
Submission time: | 2023-10-30 10:33:24 +0200 |
Language: | C++ (C++17) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:25:17: error: redeclaration of 'std::string string' 25 | std::string string = solve(string); | ^~~~~~ input/code.cpp:23:17: note: 'std::string string' previously declared here 23 | std::string string; | ^~~~~~
Code
#include <iostream> #include <string> std::string solve(const std::string& string) { std::string solved_string; char c; int v; for (size_t i=0; i < string.length(); i++) { c = string[i]; v = string[i] - '0'; if (0 < v && v < 10) { solved_string += solve(string.substr(i+1, v)); continue; } solved_string += c; } return solved_string; } int main() { std::string string; std::cin >> string; std::string string = solve(string); std::cout << string << '\n'; return 0; }