验证中...
Languages: C
Categories: 其他
Latest update 2019-08-13 19:18
gistfile1.txt
Raw Copy
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
bool is_B(char c)
{
if(c>='A'&&c<='F')
{
return true;
}return false;
}
int main()
{
char str[100]={};
while(scanf("%s",str)!=EOF)
{
long sum=0;
int n=0;
int i;
for(i=strlen(str);str[--i]!='x';)
{
if(is_B(str[i]))
{
sum+=(str[i]-55)*pow(16,n);
}else sum+=(str[i]-48)*pow(16,n);
n++;
}
printf("%ld\n",sum);
}
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search