Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- int *avtomorf(int *array, int n)
- {
- bool *check = new bool[n];
- int amount = 0;
- for (int i = 0; i<n; i++)
- {
- int del = 1;
- while (array[i] / del != 0)
- {
- del *= 10;
- }
- if ((array[i] * array[i] - array[i]) % del == 0) {
- check[i] = true;
- ++amount;
- cout << amount << endl;
- }
- else {
- check[i] = false;
- }
- }
- // Вводим их в массив
- int *result = new int[amount];
- int j = 0;
- for (int i = 0; i < n; i++)
- {
- if (check[i]) {
- result[j] = array[i];
- ++j;
- }
- }
- sort(result, result + amount);
- for (int i = 0; i < amount; i++)
- cout << result[i] << ' ';
- return result;
- }
- int main()
- {
- const int n = 10;
- int mas[n] = { 1,5,36,9,35,8,625,10,3,376 };
- int *a = avtomorf(mas, n);
- if (a != NULL)
- delete[]a;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement