Untitled
unknown
plain_text
a year ago
774 B
2
Indexable
Never
#include <iostream> #include <string> int main() { std::string str = "A%3,B:4,C:2,D%3,E:5"; std::string keys = ""; // String to store keys for (int i = 0; i < str.size(); i++) { if (str[i] >= 'A' && str[i] <= 'Z') { char key = str[i]; if (keys.find(key) != std::string::npos) continue; int value; if (str[i + 1] == ':' || str[i + 1] == '%') { // Check ':' or '%' value = str[i + 2] - '0'; // Convert char digit to int } if (value <= 3) { keys += key; // Append the key std::cout << key << std::endl; } } } return 0; }