3102. 进制转换

Naive函数字符串

时间限制:2000 ms

内存限制:256 MiB

题面

定义一个函数 h2ih2i,将一个字符串表示的 1616 进制数转换成一个 1010 进制数。

//********** Specification of hex2int **********
unsigned h2i(char s[]);
/* PreCondition:
s is a string consisting of 0~9,A-F or a-f with at most 8 characters
PostCondition:
return a decimal number equivalent to s
Examples: "100" ==> 256 ; "a" ==> 10 ; "0"==> 0
*/

只需按要求写出函数定义,并使用给定的测试程序测试你所定义函数的正确性。

不要改动测试程序。

测试正确后,将测试程序和函数定义一起提交。

/***************************************************************/
/*                                                             */
/*  DON'T MODIFY main function ANYWAY!                         */
/*                                                             */
/***************************************************************/
#include <stdio.h>
#define N 8

//********** Specification of hex2int **********
unsigned h2i(char s[])
/*
PreCondition:
s is a string consisting of 0~9,A-F or a-f with at most 8 characters
PostCondition:
return a decimal number equivalent to s
Examples: "100"==>256 ; "a"==> 10 ; "0"==> 0
*/
{
	//TODO: your function definition
}
/***************************************************************/
int main()
{
	char s[N+1];
	scanf("%s",s);
	//********** hex2int is called here ****************
	printf("%u\n",h2i(s));
	//**************************************************
	return 0;
}

样例

输入

100

输出

256