fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int na10(string dana) {
  6. int pom = 0;
  7. int dl = dana.length();
  8. for (int i = 0; i < dl; i++){
  9. int x = int(dana[dl-i-1]) - 48;
  10. pom = pom + x * pow(8, i);
  11. }
  12. return pom;
  13. }
  14.  
  15. int main() {
  16. cout << na10("174") << endl;
  17. cout << na10("362373") << endl;
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0.01s 5276KB
stdin
1
2
10
42
11
stdout
124
124155