1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include <iostream>
#include <vector>
using namespace std;
struct Massive {
int a;
int b;
int c;
int d;
int e;
};
Massive Sort(Massive smth);
int Compare(Massive array[], int N, int current);
int main() {
int N;
cout << "Insert an integer: ", cin >> N;
vector <Massive> array(N);
for (int i = 0; i < N; ++i)
array[i] = Sort(array[i]);
for (int j = 0; j < N; ++j)
cout << "Equal with massive >>" << j << "<< " << Compare(array[N], N, j) << endl;
return 0;
}
Massive Sort(Massive smth) {
int temp[5];
temp[0] = smth.a, temp[1] = smth.b, temp[2] = smth.c, temp[3] = smth.d, temp[4] = smth.e;
for (int i = 0; i < 4; ++i) {
if (temp[i] > temp[i + 1]) {
temp[i] ^= temp[i + 1];
temp[i + 1] ^= temp[i];
temp[i] ^= temp[i + 1];
}
}
smth.a = temp[0], smth.b = temp[1], smth.c = temp[2], smth.d = temp[3], smth.e = temp[4];
return smth;
}
int Compare(Massive array[], int N, int current) {
int counter = 0;
for (int i = 0; i < N; ++i) {
if (current != i && array[current].a == array[i].a)
++counter;
}
return counter;
}
|