标签:进制 end info https tps image png stream using
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int Atoi( string str , int N ){ //N进制转10进制,输入string 输出int
int ans = 0;
for( int i = 0 ; i < str.size() ; i++){
if(str[i] >= ‘0‘ && str[i] <= ‘9‘)
ans = ans * N + str[i] - ‘0‘;
else
ans = ans * N + str[i] - ‘A‘ + 10;
}
return ans;
}
string Itoa( int num , int M ){ //10进制转M进制, 输入int ,输出string
string ans = "";
do{
int t = num % M;
if( t >= 0 && t <= 9 )
ans += t + ‘0‘;
else
ans += t - 10 + ‘A‘;
num /= M;
}while( num != 0 );
reverse( ans.begin() , ans.end() );
return ans;
}
int main(){
int n , m;
string s1;
cin >> n >> s1 >> m;
int num1;
num1 = Atoi( s1 , n ); // 先把n进制转10进制
string s2;
s2 = Itoa( num1 , m ); //再将10进制转m进制
cout << s2 << endl;
return 0;
}
标签:进制 end info https tps image png stream using
原文地址:https://www.cnblogs.com/w-w-t/p/13159068.html