Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. int des9(int a, int n)
  5. {
  6. int i,des=0;
  7. for (i = 0; i < n; i++)
  8. {
  9.  
  10. des += (a % 10) * pow(3, i);
  11. a = a / 10;
  12. }
  13. return des;
  14. }
  15. int counter(int temp)
  16. {
  17. int k = 1;
  18. while (temp >= 17)
  19. {
  20. temp /= 17;
  21. k++;
  22. }
  23. return k;
  24. }
  25. int main()
  26. {
  27. char s17;
  28. int i,a, n = 1,des=0,temp,k;
  29. cin >> a;
  30. temp = a;
  31. while ((temp /= 10) > 0) n++;
  32. des = des9(a, n);
  33. /*for (i = 0; i < n; i++)
  34. {
  35.  
  36. des += (a%10) * pow(3,i);
  37. a = a / 10;
  38. }*/
  39. /*temp = des;
  40. while (temp >= 17)
  41. {
  42. temp /= 17;
  43. k++;
  44. }*/
  45. k = counter(des);
  46. while (k != 0)
  47. {
  48. int h = pow(17, k - 1);
  49. if (((des / h) % 17) > 9) s17 = des / h % 17 + '7';
  50. else s17 = des / h % 17 + '0';
  51. k--;
  52. cout << s17;
  53. }
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement