33 строки
750 B
C++
33 строки
750 B
C++
#include <iostream>
|
|
#include <cmath>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
int N;
|
|
cout << "Enter the total number of elements (N): ";
|
|
cin >> N;
|
|
|
|
int columns;
|
|
string formula_used;
|
|
|
|
if (N == 0) {
|
|
columns = 0;
|
|
formula_used = "None (N is 0)";
|
|
} else {
|
|
double sqrt_value = sqrt(N);
|
|
|
|
if (sqrt_value > 25) {
|
|
columns = 1 + static_cast<int>(log2(N));
|
|
formula_used = "Sturges' formula (1 + floor(log2(N)))";
|
|
} else {
|
|
columns = static_cast<int>(sqrt_value);
|
|
formula_used = "Square root formula (sqrt(N))";
|
|
}
|
|
}
|
|
|
|
cout << "Number of columns: " << columns << endl;
|
|
cout << "Formula used: " << formula_used << endl;
|
|
|
|
return 0;
|
|
} |