Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication14.cpp: главный файл проекта.
- #include "stdafx.h"
- #include <iostream>
- #include "windows.h"
- #include <cstdlib>
- #include "math.h"
- using namespace std;
- bool counted(int* m, int p, int q) {
- if (p == 0) {
- return false;
- }
- for (int i = 0; i < p; i++){
- if (m[i] == q) {
- return true;
- }
- }
- return false;
- }
- void main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int n, m = 0, k, q;
- cout << "Введите количество элементов массива" << endl;
- cin >> n;
- int *a = new int[n];
- for (int i = 0; i < n; i++) {
- k = 1;
- cout << "Введите " << i + 1 << "-ый элемент массива : ";
- cin >> a[i];
- while (a[i] / (int)pow(10, k) != 0 && a[i] >= 10)
- k++;
- k--;
- if ((a[i] / (int)pow(10, k)) % 2 == 0)
- m++;
- }
- cout << endl;
- int *b = new int[n - m];
- int *c = new int[n - m];
- k = 0;
- for (int i = 0; i < n; i++) {
- q = 1;
- while (a[i] / (int)pow(10, q) != 0)
- q++;
- q--;
- if ((a[i] / (int)pow(10, q)) % 2 != 0) {
- b[k] = a[i];
- k++;
- }
- }
- int t, p = 0;
- for (int i = 0; i < n - m - 1; i++) {
- t = 1;
- if (!counted(c, p, b[i])) {
- for (int j = i + 1; j < n - m; j++) {
- if (b[j] == b[i]) {
- t++;
- }
- }
- if (t > 1) {
- cout << "Найдено " << t << " элементов " << b[i] << endl;
- c[p] = b[i];
- p++;
- }
- }
- }
- for (int i = 0; i < n - m; i++) {
- cout << b[i] << ' ';
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement