Сommit
						0bc7ff4c22
					
				| @ -0,0 +1,124 @@ | ||||
| #include <iostream> | ||||
| #include <math.h> | ||||
| #include <vector> | ||||
| using namespace std; | ||||
| 
 | ||||
| int main() | ||||
| { | ||||
|     size_t colls; | ||||
|     size_t quantity; | ||||
|     size_t height; | ||||
|     cerr << "vvedite kolichestvo chisel" << endl; | ||||
|     cin >> colls; | ||||
|     vector<float> 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"<<endl; | ||||
|         cin >> height; | ||||
|         if (height < colls / 3 - 4 && height < 3 && height>76) | ||||
|         { | ||||
|             cerr << "vvedena nevernaya velichina gistogrammy. vvedite novoe znachenie"<<endl; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             heightbl = true; | ||||
|             exit; | ||||
|         } | ||||
|     } | ||||
|     height = height - 4; | ||||
|     float minimum = numbers[0]; | ||||
|     for (int i = 0; i < colls; i++) | ||||
|     { | ||||
|         if (numbers[i] < minimum) | ||||
|         { | ||||
|             minimum = numbers[i]; | ||||
|         } | ||||
|     } | ||||
|     float maximum = numbers[0]; | ||||
|     for (int i = 0; i < colls; i++) | ||||
|     { | ||||
|         if (numbers[i] > maximum) | ||||
|         { | ||||
|             maximum = numbers[i]; | ||||
|         } | ||||
|     } | ||||
|     float low = minimum; | ||||
| 
 | ||||
|     float diff = (maximum - minimum) / quantity; | ||||
|     float high = minimum+diff; | ||||
|     vector<int> 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<double>(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; | ||||
| } | ||||
					Загрузка…
					
					
				
		Ссылка в новой задаче
	
	 AngelovIvan
						AngelovIvan