标签:
水题一个,发一发我美美的代码。
1 #include <iostream> 2 #include <cstring> 3 #include <cctype> 4 using namespace std; 5 6 const int N = 9; 7 char num[N]; 8 9 int standard( char ch ) 10 { 11 if ( isdigit(ch) ) return ch - ‘0‘; 12 if ( isupper(ch) ) return ch - ‘A‘ + 10; 13 } 14 15 int ans() 16 { 17 int res = 0; 18 for ( int i = 0; i < strlen(num); i++ ) 19 { 20 res = res * 16 + standard(num[i]); 21 } 22 return res; 23 } 24 25 int main () 26 { 27 while ( cin >> num ) 28 { 29 cout << ans() << endl; 30 } 31 return 0; 32 }
标签:
原文地址:http://www.cnblogs.com/huoxiayu/p/4411120.html