Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<math.h>
- long long htoi(char s[])
- {
- int len=strlen(s);
- int i,j=0;
- long long hed,sum=0;
- for(i=len-1;i>=0;i--)
- {
- if(s[i]>='0' && s[i]<='9')
- {
- hed=s[i]-'0';
- }
- else if(s[i]>='A' && s[i]<='F')
- {
- hed=(s[i]-'A')+10;
- }
- else if(s[i]>='a' && s[i]<='f')
- {
- hed=(s[i]-'a')+10;
- }
- sum+=pow(16,j)*hed; //otheres ot decimat always power method
- j++;
- }
- return sum;
- }
- int main()
- {
- int i;
- char s[1000];
- scanf("%s",s);
- long long gross=htoi(s);
- printf("%lld\n",gross);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement