您的位置:首页 > 其它

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

2013-12-02 01:20 661 查看

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: