Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Base conversion
//g++ 5.4.0 #include <iostream> int returnDecimal(char c); char base36_digits[36] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; int main() { int testCases; int baseOrig; int baseConvert; char orignal = 'N'; char convert = '2'; int value = 50000; std::string result; int index = 0; int baseValue1= returnDecimal(orignal); int baseValue2= returnDecimal(convert); int converted_number[64]; while(value != 0){ converted_number[index] = value%baseValue1; value = value / baseValue1; ++index; //result=result +value; } --index; //backup to the last entry index for( ; index > 0 ;index--){ std::cout<<converted_number[index]; } // while(testCases--){ //} } int returnDecimal(char c){ int decimalValue =0; for(int i=0;i<36;i++){ if(base36_digits[i] == c){ decimalValue = i; } } return decimalValue+1; }
run
|
edit
|
history
|
help
0
3
abbinsertbool
Вывод элементов массива
SOS DP
merge without extra space Gap method ALgorithm
string iteration performance
sin_approximation
Find value in sorted matrix
UtilityPair2
AgeGroupHisto