lordbluehimself

shibanoDomashno

Nov 18th, 2020
1,393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <stack>
  5.  
  6. using namespace std;
  7.  
  8. void strToNum() {
  9.     int num;
  10.     cin >> num;
  11.     string converter = to_string(num);
  12.     for (int i = 0; i < converter.length(); i++) {
  13.         char oneDigit = converter[i];
  14.         int a = 0;
  15.             for (int j = 0; j < converter.length(); j++) {
  16.                 //a = atoi(oneDigit);
  17.             }
  18.         }
  19. }
  20.  
  21. void numDigits() {
  22.     stack <int> popper;
  23.     int num, a;
  24.     cout << "Enter your number: ";
  25.     cin >> num;
  26.     while (num != 0) {
  27.         a = num % 10;
  28.         num = num / 10;
  29.         popper.push(a);
  30.     }
  31.  
  32.     while (!popper.empty()) {
  33.         int a = popper.top();
  34.         popper.pop();
  35.         cout << a << endl;
  36.     }
  37. }
  38.  
  39. void noStackDigit() {
  40.     int num;
  41.     cin >> num;
  42.     string converter = to_string(num);
  43.     for (int i = 0; i < converter.length(); i++) {
  44.         cout << converter[i] << endl;
  45.     }
  46. }
  47.  
  48. void shibanoDomashno(int n) {
  49.     //Transform int n to binary;
  50.     int binaryNum[32];
  51.  
  52.     int i = 0;
  53.     while (n > 0) {
  54.         binaryNum[i] = n % 2;
  55.         n = n / 2;
  56.         i++;
  57.     }
  58.     for (int j = i - 1; j >= 0; j--) {
  59.         cout << binaryNum[j];
  60.     }
  61. }
  62.  
  63. void mishevOne() {
  64.     int a, b, n;
  65.     cout << "Enter a, b and n: ";
  66.     cin >> a >> b >> n;
  67.     int count = 0;
  68.     for (int an = 1, bn = n; an <= n; an++, bn--) {
  69.         count += pow(a, an) * pow(b, bn);
  70.     }
  71.     cout << count;
  72. }
  73.  
  74. int reverse(int n) {
  75.     int rev = 0;
  76.     while (n != 0) {
  77.         rev = (rev * 10) + (n % 10);
  78.         n /= 10;
  79.     }
  80.     return rev;
  81. }
  82.  
  83. void mishevTwo(int n) {
  84.     int a = reverse(n);
  85.     int odd, even, c = 1;
  86.     while (a != 0) {
  87.         if (c % 2 == 0) {
  88.             even = a % 3;
  89.             cout << even;
  90.         }
  91.         else {
  92.             odd = a % 2;
  93.             cout << odd;
  94.         }
  95.         a /= 10;
  96.         c++;
  97.     }
  98. }
  99.  
  100.  
  101. int main()
  102. {
  103.     int a;
  104.     cout << "Enter a 5 digit number: ";
  105.     cin >> a;
  106.     mishevTwo(a);
  107.     return 0;
  108. }
  109.  
Advertisement
Add Comment
Please, Sign In to add comment