Untitled
unknown
plain_text
3 years ago
774 B
10
Indexable
#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;
}
Editor is loading...