srand(time(0));
const int size=10;
int A[size]{};
cout << "Massive A:" << endl;
for (int i = 0; i < size; i++) {
}
cout << endl;
int tmp;
for (int i = 0, j = 0; i < size; i++) {
}
int res = 0;
int max_index = 0;
int max_value = 0;
for (int i = 0; i < size; i++) {
}
cout << "Moda:" << max_value << endl;
system("pause");
const int size=10;
int A[size]{};
cout << "Massive A:" << endl;
for (int i = 0; i < size; i++) {
A[i] = rand() % 51;
cout << A[i] << "\t";
}
cout << endl;
int tmp;
for (int i = 0, j = 0; i < size; i++) {
tmp = A[i];
for (j = i - 1; j >= 0 && A[j] > tmp; j--) {
A[j + 1] = A[j];}
A[j + 1] = tmp;
}
int res = 0;
int max_index = 0;
int max_value = 0;
for (int i = 0; i < size; i++) {
if (A[i] == A[i + 1]) {
res++;}
max_value = A[i];
if (res > max_index) {
max_index = res;
}
}
cout << "Moda:" << max_value << endl;
system("pause");
Комментариев нет:
Отправить комментарий