Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include <iostream>
  2. #include<cmath>
  3. #include<algorithm>
  4. #include<string>
  5. #include<windows.h>
  6. using namespace std;
  7. //из 14 в 6
  8. // 9=14 17=6
  9. int main()
  10. {
  11.  
  12. SetConsoleCP(1251);
  13. SetConsoleOutputCP(1251);
  14. int sch14, sch6, sch10 = 0;
  15. cout << "введите число в 14ричной сс" << endl;
  16. cin >> sch14;
  17. cout << endl;
  18. string str = "";
  19. int arr[100];
  20. int i = 0;
  21. while (sch14 >= 1)
  22. {
  23. sch10 += sch14 % 10 * pow(14, i);
  24. sch14 /= 10;
  25. i++;
  26. }
  27. cout << "ваше число в 10ричной сс = " << sch10 << " =ans";
  28. i = 0;
  29. while (sch10 >= 1)
  30. {
  31. if (sch10 % 6 > 14)
  32. {
  33. char s = sch10 % 6 + 55;
  34. cout << s;
  35. str += sch10 % 6 + 55;
  36. arr[i] = sch10 % 6 + 7;
  37. }
  38. else
  39. {
  40. char s = sch10 % 6 + 48;
  41. cout << s;
  42. str += sch10 % 6 + 48;
  43. arr[i] = sch10 % 6;
  44. }
  45. i++;
  46. sch10 /= 6;
  47. }
  48. int len = i;
  49. reverse(str.begin(), str.end());
  50. cout << endl;
  51. cout << endl << "использована строка= " << str << endl << "использован массив= ";
  52. for (i = 0; i < len; i++)
  53. {
  54. char buf = '0' + arr[len - i - 1];
  55. cout << buf;
  56.  
  57. }
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement