#include <iostream>
#include <string>
using namespace std;
void zamiana(int n, int g)
{
int a=n, ile_razy=0, c=0, reszta;
while(a!=0)
{
a/=g;
ile_razy++;
}
int tab[ile_razy];
while(n!=0)
{
tab[c]=n%g;
n/=g;
c++;
}
for(int g=ile_razy-1; g>=0; g--) cout << tab[g];
}
void na_16(int n, int g)
{
int a=n, ile_razy=0, c=0, reszta;
while(a!=0)
{
a/=g;
ile_razy++;
}
char tab[ile_razy];
while(n!=0)
{
switch(n%16)
{
case 10: tab[c]='A';
break;
case 11: tab[c]='B';
break;
case 12: tab[c]='C';
break;
case 13: tab[c]='D';
break;
case 14: tab[c]='E';
break;
case 15: tab[c]='F';
break;
default: tab[c]=n%16+48;
break;
}
n/=16;
c++;
}
for(int g=ile_razy-1; g>=0; g--) cout << tab[g];
}
int main()
{
int n, g;
cout << "Podaj liczbe do zamiany: "; cin >> n;
cout << "Podaj XDpodstawe potegi: "; cin >> g;
cout << "Zamieniona liczba o podstawie potegi: "<< g << ": ";
if(g<=10) zamiana(n, g);
else if(g==16) na_16(n, g);
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}