Skip to content

Instantly share code, notes, and snippets.

@dafr32
Created February 26, 2014 11:22
Show Gist options
  • Save dafr32/9227819 to your computer and use it in GitHub Desktop.
Save dafr32/9227819 to your computer and use it in GitHub Desktop.
Dowolny na dziesiętny
#include <iostream>
using namespace std;
int Horner(string liczba, int syst)
{
int suma=0;
for(int i=0;i<liczba.length();i++ )
{
int a = liczba[i]-'0'; //kod 0 = 48
if (a > 9) a-=7;
suma= suma*syst + a;
}
return suma;
}
int main()
{
string liczba,l;
int syst;
cout << "Podaj liczbe: " ; cin>>l;
liczba=l;
cout << "Podaj system: " ; cin>>syst;
cout << "liczba (" << l<< ")=" << Horner(liczba,syst);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment