码迷,mamicode.com
首页 > 其他好文 > 详细

toj 4093 水题

时间:2015-04-09 21:17:13      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:

水题一个,发一发我美美的代码。

 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 }

toj 4093 水题

标签:

原文地址:http://www.cnblogs.com/huoxiayu/p/4411120.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!