10473 - Simple Base Conversion
Time limit: 3.000 seconds
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;
}