UVa 10473 Simple Base Conversion (两句话实现进制转换)

来源:互联网 发布:淘宝快递代发 编辑:程序博客网 时间:2024/05/17 19:17

10473 - Simple Base Conversion

Time limit: 3.000 seconds 

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1414


10->16:atoi+%X

16->10:strtol+%d


完整代码:

/*0.019s*/#include<cstdio>#include<cstdlib>char s[15];int main(){while (gets(s), s[0] != '-')if (s[1] == 'x') printf("%d\n", strtol(s, NULL, 16));else printf("0x%X\n", atoi(s));///注意十六进制中的字母要大写return 0;}