1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 |
#include <iostream> #include <cstring> #include <cmath> #include<stdio.h> #include <stdlib.h> using
namespace
std; void
swapOXtoTEN( char
*s) { int
len = strlen (s); __int64
a=0; for ( int
i=0;i<len;i++) { if (s[i]<=57&&s[i]>=48) { a+=(s[i]-48)* pow (16,len-i-1); } else { a+=(s[i]-55)* pow (16,len-i-1); } } printf ( "%I64d\n" ,a); } int
main() { char
s[21]; while (cin>>s) { swapOXtoTEN(s); } return
0; } |
主意printf的头文件
此代码仅供参考。
原文:http://www.cnblogs.com/MonkeyAC/p/3525984.html