Hi everyone! I've wanted to ask whether my code culture (and the algorithm itself) is good, because I feel like my previous knowledge of python is eating into my c++ code and making it pythonic, if that makes sense
Task on picture.
#include <string>
std::string sdf;
std::string spaceMessage(std::string str) {
std::string decrypted;
for (int i = 0; i<str.size(); i++){
if (str.at(i) == '['){
int count = str.at(i+1) - '0';
int j = i;
while (str.at(j) != ']'){
j++;
}
for (int k = 0; k < count; k++){
decrypted.append(str.substr(i+2, j - i - 2));
}
i = j;
}
else{
if (str.at(i) != ']') {
decrypted.push_back(str.at(i));
}
else {
}
}
}
return decrypted;
}
int main() {
std::cout << spaceMessage("ABCD") << std::endl;
}```