赞
踩
- #include<cstdio>
- #include<iostream>
- #include<algorithm>
- #include<cstring>
-
- using namespace std;
-
- char ans[100];
-
- int main()
- {
- while(scanf("%s",ans+1)!=EOF)
- {
- int len=strlen(ans+1);
- long long sum=0,d;
-
- for(int i=len;i>=1;i--)
- {
- if(ans[len-i+1]>='0' && ans[len-i+1]<='9')
- d=ans[len-i+1]-'0';
- else
- d=ans[len-i+1]-'A'+10;
- for(int j=1;j<i;j++)
- {
- d=d*16;
- }
- sum+=d;
- }
- printf("%I64d\n",sum);
- memset(ans,0,sizeof(ans));
- }
- return 0;
- }
- #include<cstdio>
- #include<iostream>
- #include<cstring>
-
- using namespace std;
-
- char a[100];
-
- int main()
- {
- while(scanf("%s",a+1)!=EOF)
- {
- long long sum=0,d;
- int len=strlen(a+1);
- for(int i=1;i<=len;i++)
- {
- if(a[i]>='0' && a[i]<='9')
- d=a[i]-'0';
- else
- d=a[i]-'A'+10;
- for(int j=0;j<len-i;j++)
- d=d*16;
- sum+=d;
- }
- printf("%I64d\n",sum);
- memset(a,0,sizeof(a));
- }
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。