Created
February 26, 2014 11:22
-
-
Save dafr32/9227819 to your computer and use it in GitHub Desktop.
Dowolny na dziesiętny
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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