toj 4093 简单题

简单题。

 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 }
posted @ 2015-04-09 19:32  hxy_has_been_used  阅读(110)  评论(0编辑  收藏  举报