#include <iostream>
#include <string>
#include <sstream>
int main( )
{
while ( true )
{
std:: cout << std:: endl ;
std:: string input;
if ( ! std:: getline ( std:: cin , input) )
{
std:: cout << "End of input" << std:: endl ;
break ;
}
bool understood = false ;
//Try to read it as a number
{
int n;
if ( std:: istringstream ( input) >> n)
{
std:: cout << "You entered a number: " << n << std:: endl ;
understood = true ;
}
}
//Try to interpret it as a character
if ( input.length ( ) == 1 )
{
std:: cout << "You entered a character: " << static_cast < int > ( input[ 0 ] ) << std:: endl ;
understood = true ;
}
//Otherwise, just give back what we got
if ( ! understood)
{
std:: cout << "You entered something else: \" " << input << "\" " << std:: endl ;
}
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c3N0cmVhbT4KCmludCBtYWluKCkKewoJd2hpbGUodHJ1ZSkKCXsKCQlzdGQ6OmNvdXQgPDwgc3RkOjplbmRsOwoKCQlzdGQ6OnN0cmluZyBpbnB1dDsKCQlpZighc3RkOjpnZXRsaW5lKHN0ZDo6Y2luLCBpbnB1dCkpCgkJewoJCQlzdGQ6OmNvdXQgPDwgIkVuZCBvZiBpbnB1dCIgPDwgc3RkOjplbmRsOwoJCQlicmVhazsKCQl9CgoJCWJvb2wgdW5kZXJzdG9vZCA9IGZhbHNlOwoJCQoJCS8vVHJ5IHRvIHJlYWQgaXQgYXMgYSBudW1iZXIKCQl7CgkJCWludCBuOwoJCQlpZihzdGQ6OmlzdHJpbmdzdHJlYW0oaW5wdXQpID4+IG4pCgkJCXsKCQkJCXN0ZDo6Y291dCA8PCAiWW91IGVudGVyZWQgYSBudW1iZXI6ICIgPDwgbiA8PCBzdGQ6OmVuZGw7CgkJCQl1bmRlcnN0b29kID0gdHJ1ZTsKCQkJfQoJCX0KCQkKCQkvL1RyeSB0byBpbnRlcnByZXQgaXQgYXMgYSBjaGFyYWN0ZXIKCQlpZihpbnB1dC5sZW5ndGgoKSA9PSAxKQoJCXsKCQkJc3RkOjpjb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