#include <iostream>
using namespace std;
int fib(int number)
{
int value = 0;
if(number < 1) return 0;
if(number == 1) return 1;
return fib(number-1) + fib(number - 2);
}
int main()
{
int row = 15;
int column = 15;
int arr[row][column];
int arrQuantity[15];
for (int i = 0; i < column; i++)
{
for (int j = 0; j < row; j++){
arr[i][j] = rand()%100-50;
cout << arr[i][j] << "\t";
}
cout << endl;
}
for (int i = 0; i < row; i++){
arrQuantity[i] = 0;
for (int k = 0; k < column; k++){
for(int j = 0; j < 13; j++){
if(arr[i][k] == fib(j))
arrQuantity[i] +=1;
}
}
}
cout << "Кількість чисел Фібоначчі: " ;
for(int i = 0; i < column; i++)
cout << arrQuantity[i];
for(int i = 0; i < column; i++){
if(arrQuantity[i] > arrQuantity[i + 1]){
for(int j = 0; j < row; j++){
swap(arr[i][j], arr[i + 1][j]);
}
}
}
cout << "\n\n\n";
for (int i = 0; i < column; i++){
for (int j = 0; j < row; j++)
cout << arr[i][j] << "\t";
cout << endl;
}
return 0;
}
Нужно улучшить программу. Смысл программы в том, чтобы отсортировать столбцы массива по количеству в столбцах чисел Фибоначчи. Сортировать нужно по возрастанию, то есть слева направо.