Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <locale>
- using namespace std;
- ifstream f("ishod.txt", ios::in);
- bool function(int a){
- int b;
- bool posl = true;
- b = a % 10;
- a /= 10;
- while (a > 0){
- if (a % 10 >= b){
- posl = true;
- b = a % 10;
- }
- else{
- posl = false;
- break;
- }
- a /= 10;
- }
- return posl;
- }
- int* form_mas(int a){
- int b = 0;
- int* massive = new int[a];
- for (int i = 0; i < a; i++){
- f >> b;
- massive[i] = b;
- }
- return massive;
- }
- void main(){
- setlocale(LC_ALL, "rus");
- int a,i;
- f >> a;
- int* mass = form_mas(a);
- cout << "Исходный массив : " << endl;
- for (i = 0; i < a; i++){
- cout << mass[i] << endl;
- }
- cout << endl;
- for (int k = a - 1; k>-1; k--){
- if (function(mass[k]))
- {
- for (i = k; i < a - 1; i++)
- mass[i] = mass[i + 1]; // a[i] – указывает, куда сдвигаем
- a--;
- }
- }
- cout << "Массив после обработки" << endl;
- cout << endl;
- for (i = 0; i < a; i++){
- cout << mass[i] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment