首页 > 其他 > 详细

toj 4093 水题

时间:2015-04-09 21:15:28      阅读:130      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!