Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int IncrCheck(int num) {
  8.     int buf = abs(num);
  9.     if (buf < 10) return 1;
  10.     while (buf > 9) {
  11.         if (buf % 10 < (buf % 100 - buf % 10) / 10) return 0;
  12.         buf /= 10;
  13.     }
  14.     return 1;
  15. }
  16.  
  17. int main()
  18. {
  19.     setlocale(LC_ALL, "rus");
  20.     int num, size = 0, i = 0;
  21.     int *save = new int[size];
  22.     cout << "Ввод последовательности: " << endl;
  23.     cin >> num;
  24.     while (num) {
  25.         if (IncrCheck(num)) {
  26.             save[size] = num;
  27.             size++;
  28.         }
  29.         cin >> num;
  30.     }
  31.     cout << "Числа последовательности, в которых цифры расположены в порядке возрастания от старшего к младшему члену: " << endl;
  32.     for (int j = 0; j < size; j++)
  33.         cout << save[j] << " ";
  34.     delete[] save;
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement