#include #include #include using namespace std; int main() { size_t colls; size_t quantity; size_t height; cerr << "vvedite kolichestvo chisel" << endl; cin >> colls; vector numbers(colls); cerr << "vvedite massiv" << endl; for (int i = 0; i < colls; i++) { cin >> numbers[i]; } cerr << "vvedite kolichestvo diapazonov" << endl; cin >> quantity; bool heightbl = false; while (!heightbl) { cerr << "vvedite velichiny gistogrammy"<> height; if (height < colls / 3 - 4 && height < 3 && height>76) { cerr << "vvedena nevernaya velichina gistogrammy. vvedite novoe znachenie"< maximum) { maximum = numbers[i]; } } float low = minimum; float diff = (maximum - minimum) / quantity; float high = minimum+diff; vector count(quantity); for (int i = 0; i < quantity; i++) { if (i + 1 == quantity) { high=maximum; } int sum = 0; for (int j = 0; j < colls; j++) { if (numbers[j] < high && numbers[j] >= low && high!=maximum) { sum++; } if (high == maximum && numbers[j] <= high && numbers[j] >= low) { sum++; } } count[i] = sum; low += diff; high += diff; } int maxnum = 0; int maxcount = count[0]; for (int i = 0; i < quantity; i++) { if (maxcount > count[i]) { maxcount = count[i]; maxnum = i; } } for (int i = 0; i < quantity; i++) { if (count[i] < 100) { cout << " "; } if (count[i] < 10) { cout << " "; } cout << count[i] << " | "; if (maxcount > height) { count[i] = height * (static_cast(count[i]) / maxcount); for (int j = 0; j < count[i]; j++) { cout << "*"; } cout << endl; } else { for (int j = 0; j < count[i]; j++) { cout << "*"; } cout << endl; } } getchar(); getchar(); return 0; }