" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2025 KUDO.TIPS - All rights reserved.
#include <iostream>
#include <vector>
void zamiana(std::vector<std::string>& vec)
{
char tab[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
std::cout << "Podaj ilosc liczb do zamiany: ";
int n;
std::cin >> n;
for (int i = 0; i < n; ++i)
{
std::string str;
long var;
int sys;
std::cin >> var >> sys;
while (var > 1000000000)
std::cin >> var;
while (sys < 2 || sys > 16)
std::cin >> sys;
int r = var;
while (var > 0)
{
r = var % sys;
var /= sys;
str += tab[r];
}
std::string ret;
for (int j = str.size()-1; j >= 0; --j)
{
ret += str[j];
}
vec.push_back(ret);
}
}
int main()
{
std::vector<std::string> vec;
zamiana(vec);
for (int i = 0; i < vec.size(); ++i)
std::cout << vec[i] << std::endl;
}