Можно так:
#include <iostream>
#include <vector>
std::vector<std::string> digit{"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
int main()
{
int oneD;
std::string inStr;
while (std::cin >> inStr) {
if (inStr.length() < 2) {
try {
oneD = stoi(inStr);
}
catch (...) {
continue;
}
std::cout << std::endl << digit[oneD] << std::endl;
} else {
for (auto iter = 0; iter < digit.size(); iter++) {
if (digit[iter] == inStr) {
std::cout << std::endl << iter << std::endl;
continue;
}
}
}
}
return 0;
}