#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int ActionGenerator() {
int Action;
string Input = "";
while(true) {
cout << endl << "SELECIONE UMA ACTION: " << endl;
cout << "[1 = ActionX]" << endl << "[2 = ActionZ]" << endl;
getline(cin, Input);
stringstream myStream(Input);
if ((myStream >> Action) && (Action == 1 || Action == 2)) return Action;
else cout << endl << "ACTION INVALIDA !" << endl;
}
}
int main() {
cout << ActionGenerator() << endl << "ok" <<endl;
}
//https://pt.stackoverflow.com/q/41855/101
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c3N0cmVhbT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgQWN0aW9uR2VuZXJhdG9yKCkgewogICAgaW50IEFjdGlvbjsKICAgIHN0cmluZyBJbnB1dCA9ICIiOwogICAgd2hpbGUodHJ1ZSkgewogICAgICAgIGNvdXQgPDwgZW5kbCA8PCAiU0VMRUNJT05FIFVNQSBBQ1RJT046ICIgPDwgZW5kbDsKICAgICAgICBjb3V0IDw8ICJbMSA9IEFjdGlvblhdIiA8PCBlbmRsIDw8ICJbMiA9IEFjdGlvblpdIiA8PCBlbmRsOwogICAgICAgIGdldGxpbmUoY2luLCBJbnB1dCk7CiAgICAgICAgc3RyaW5nc3RyZWFtIG15U3RyZWFtKElucHV0KTsKICAgICAgICAgaWYgKChteVN0cmVhbSA+PiBBY3Rpb24pICYmIChBY3Rpb24gPT0gMSB8fCBBY3Rpb24gPT0gMikpIHJldHVybiBBY3Rpb247CiAgICAgICAgZWxzZSBjb3V0IDw8IGVuZGwgPDwgIkFDVElPTiBJTlZBTElEQSAhIiA8PCBlbmRsOwogICAgfQp9CgppbnQgbWFpbigpIHsKICAgIGNvdXQgPDwgQWN0aW9uR2VuZXJhdG9yKCkgPDwgZW5kbCA8PCAib2siIDw8ZW5kbDsKfQogICAgCi8vaHR0cHM6Ly9wdC5zdGFja292ZXJmbG93LmNvbS9xLzQxODU1LzEwMQ==