0
Print the First Non Repeated Character
Get the input string from the user and print the first non repeating character in the string. if there is no Non repeating character print 0. For Example input : Hello result: H input : xxyyzz result: 0
1 Réponse
+ 1
char in, cmp{'\0'};
bool repeated{false};
while (std::cin >> in)
{
if (in == cmp)
repeated = true;
if (!repeated && in != cmp)
{
std::cout << in;
break;
}
else
{
cmp = in;
repeated = false;
}
}