#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
unsigned long ul = 0;
char h[9];
int i;
scanf("%8s", h);
for(i = 0; i < strlen(h); i++)
{
if(h[i] >= '0' && h[i] <= '9')
ul += h[i] - '0';
else if(h[i] >= 'a' && h[i] <= 'f')
ul += h[i] - 'a' + 10;
else if (h[i] >= 'A' && h[i] <= 'F')
ul += h[i] - 'A' + 10;
else
puts("Error!");
if(h[i + 1])
ul *= 16;
}
printf("%lu\n", ul);
system("Pause");
return 0;
}
//END
[[it] 本帖最后由 cosdos 于 2008-10-1 02:01 编辑 [/it]]