SHARE
TWEET

Zadanie z temperatura

a guest May 20th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int Horner(string s, int p)
  7. {
  8.     int y=(int)s[0]-48;
  9.     for(int i=1; i<s.size(); i++)
  10.         y=y*p+(int)s[i]-48;
  11. return y;
  12. }
  13.  
  14. int zadanie1(string s, int p)
  15. {
  16.     int znak = 1;
  17.     if(s[0]=='-')
  18.     {
  19.         znak = -1;
  20.         s=s.substr(1, s.size()-1);
  21.     }
  22. return znak * Horner(s, p);
  23. }
  24.  
  25. int main()
  26. {
  27.     cout<<zadanie1("-1011", 2);
  28.  
  29.     return 0;
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top