def parabuf(s): s = list(s) res = 0 sign = 1 for i, ch in enumerate(s): if ch == '-': if i != 0: return 'error number!' sign = -1 elif ord(ch) > ord('9')&nbs***bsp;ord(ch) < ord('0'): return 'error number!' else: res = res * 10 + (ord(ch) - ord('0')) return sign * res
#include <iostream> using namespace std; int change( char* str ) { int base = 0; while ( *str ) { base = base * 10 + (*str) - '0'; str++; } return(base); } void main() { char str[100]; cin >> str; int value1; if ( *str == '-' ) { value1 = -1 * change( str + 1 ); }else { value1 = change( str ); } cout << value1 << endl; }