标签:stream ret -- code namespace mes ring style string
注意高位低位次序即可
#include<iostream> #include<string> #include<cmath> using namespace std; long long fun(char c,int n){ long long temp=0; int i; switch(c) { case ‘F‘: temp=15; break; case ‘E‘: temp=14; break; case ‘D‘: temp=13;break; case ‘C‘: temp=12;break; case ‘B‘: temp=11;break; case ‘A‘: temp =10;break; case ‘9‘:temp =9;break; case ‘8‘:temp =8;break; case ‘7‘:temp =7;break; case ‘6‘:temp =6;break; case ‘5‘:temp =5;break; case ‘4‘:temp =4;break; case ‘3‘:temp =3;break; case ‘2‘:temp =2;break; case ‘1‘:temp =1;break; case ‘0‘:temp =0;break; } for(i=0;i<n;i++){ temp=temp*16; } return temp; } int main(){ string a; int n,i,j; cin>>a; long long num=0; for(i=a.length()-1,j=0;i>=0;i--,j++){ num=num+fun(a[i],j); } cout<<num<<endl; }
标签:stream ret -- code namespace mes ring style string
原文地址:https://www.cnblogs.com/joker99/p/12221368.html