Написати функцію, що буде виводити десяткове число у будь-якому іншому форматі аж до основи 37 англійського алфавіту. Нажаль, більше нам заважає обмеженість алфавіту.не аикористовувати string and vector.c++
Ответы
Ответ дал:
0
С++
#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;
}
Вас заинтересует
1 год назад
1 год назад
2 года назад
8 лет назад
8 лет назад