#include <stdio.h>
int eh_inteiro( const char * c) {
int i = c[ 0 ] == '-' || c[ 0 ] == '+' ;
if ( ! c[ i] ) return 0 ;
while ( c[ i] ) {
if ( c[ i] < '0' || c[ i] > '9' ) return 0 ;
i++;
}
return 1 ;
}
void testar( const char * c) {
printf ( "%s: %s\n " , c
, eh_inteiro
( c
) ? "Sim" : "Não" ) ; }
int main( void ) {
testar( "123" ) ;
testar( "+123" ) ;
testar( "-123" ) ;
testar( "1" ) ;
testar( "0" ) ;
testar( "9" ) ;
testar( "999999" ) ;
testar( "-5" ) ;
testar( "-" ) ;
testar( "+" ) ;
testar( "" ) ;
testar( "banana" ) ;
testar( "123a" ) ;
testar( "12a3" ) ;
testar( " " ) ;
testar( " 12" ) ;
testar( "12 " ) ;
testar( "1 2" ) ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgZWhfaW50ZWlybyhjb25zdCBjaGFyICpjKSB7CiAgICBpbnQgaSA9IGNbMF0gPT0gJy0nIHx8IGNbMF0gPT0gJysnOwogICAgaWYgKCFjW2ldKSByZXR1cm4gMDsKICAgIHdoaWxlIChjW2ldKSB7CiAgICAgICAgaWYgKGNbaV0gPCAnMCcgfHwgY1tpXSA+ICc5JykgcmV0dXJuIDA7CiAgICAgICAgaSsrOwogICAgfQogICAgcmV0dXJuIDE7Cn0KCnZvaWQgdGVzdGFyKGNvbnN0IGNoYXIgKmMpIHsKICAgIHByaW50ZigiJXM6ICVzXG4iLCBjLCBlaF9pbnRlaXJvKGMpID8gIlNpbSIgOiAiTsOjbyIpOwp9CgppbnQgbWFpbih2b2lkKSB7CiAgICB0ZXN0YXIoIjEyMyIpOwogICAgdGVzdGFyKCIrMTIzIik7CiAgICB0ZXN0YXIoIi0xMjMiKTsKICAgIHRlc3RhcigiMSIpOwogICAgdGVzdGFyKCIwIik7CiAgICB0ZXN0YXIoIjkiKTsKICAgIHRlc3RhcigiOTk5OTk5Iik7CiAgICB0ZXN0YXIoIi01Iik7CiAgICB0ZXN0YXIoIi0iKTsKICAgIHRlc3RhcigiKyIpOwogICAgdGVzdGFyKCIiKTsKICAgIHRlc3RhcigiYmFuYW5hIik7CiAgICB0ZXN0YXIoIjEyM2EiKTsKICAgIHRlc3RhcigiMTJhMyIpOwogICAgdGVzdGFyKCIgIik7CiAgICB0ZXN0YXIoIiAxMiIpOwogICAgdGVzdGFyKCIxMiAiKTsKICAgIHRlc3RhcigiMSAyIik7Cn0K