С++#include <iostream>
using namespace std;
void convertToBase(int num, int base) {
char symbols[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string result = "";
while (num > 0) {
int remainder = num % base;
result = symbols[remainder] + result;
num /= base;
}
cout << result << endl;
int main() {
int number, base;
cout << "Enter a decimal number: ";
cin >> number;
cout << "Enter the base to convert to (up to 37): ";
cin >> base;
convertToBase(number, base);
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
С++
#include <iostream>
using namespace std;
void convertToBase(int num, int base) {
char symbols[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string result = "";
while (num > 0) {
int remainder = num % base;
result = symbols[remainder] + result;
num /= base;
}
cout << result << endl;
}
int main() {
int number, base;
cout << "Enter a decimal number: ";
cin >> number;
cout << "Enter the base to convert to (up to 37): ";
cin >> base;
convertToBase(number, base);
return 0;
}