#include <iostream>
#define SIZE 256
void CountOccurrences(std::string str, char occurrences[]) {
int i = 0;
int size = str.length();
while (i < size) {
occurrences[(int)str[i]]++;
i++;
}
}
char GetFirstNonRepeatedCharacter(std::string str) {
char occurrences[SIZE] = { 0 };
CountOccurrences(str, occurrences);
int i = 0;
int size = str.length();
while (i < size) {
if (occurrences[(int)str[i]] == 1) {
return str[i];
}
i++;
}
return -1;
}
int main() {
std::string str = "c c++ csharp java php python";
std::cout << GetFirstNonRepeatedCharacter(str);
}
/*
run:
s
*/