Skip to content

Instantly share code, notes, and snippets.

@dafr32
Created February 26, 2014 10:49
Show Gist options
  • Save dafr32/9227457 to your computer and use it in GitHub Desktop.
Save dafr32/9227457 to your computer and use it in GitHub Desktop.
Dziesiętna na dowolny system
#include <iostream>
using namespace std;
char intTOchar(int i)
{
if (i<10)
return i+'0';
else
return i+'A' -10;
}
int main()
{
int liczba,l,syst;
string wynik="";
cout << "Podaj liczbe: "; cin >>l;
liczba=l;
cout << "Podaj system :"; cin >>syst;
do {
wynik = intTOchar(liczba%syst) + wynik;
liczba/=syst;
} while(liczba>0);
cout << "liczba ("<< l <<") = "<<wynik<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment