Сommit
						30b826a2ed
					
				| @ -0,0 +1,40 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||||
| <CodeBlocks_project_file> | ||||
| 	<FileVersion major="1" minor="6" /> | ||||
| 	<Project> | ||||
| 		<Option title="lab01" /> | ||||
| 		<Option pch_mode="2" /> | ||||
| 		<Option compiler="gcc" /> | ||||
| 		<Build> | ||||
| 			<Target title="Debug"> | ||||
| 				<Option output="bin/Debug/lab01" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option object_output="obj/Debug/" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-g" /> | ||||
| 				</Compiler> | ||||
| 			</Target> | ||||
| 			<Target title="Release"> | ||||
| 				<Option output="bin/Release/lab01" prefix_auto="1" extension_auto="1" /> | ||||
| 				<Option object_output="obj/Release/" /> | ||||
| 				<Option type="1" /> | ||||
| 				<Option compiler="gcc" /> | ||||
| 				<Compiler> | ||||
| 					<Add option="-O2" /> | ||||
| 				</Compiler> | ||||
| 				<Linker> | ||||
| 					<Add option="-s" /> | ||||
| 				</Linker> | ||||
| 			</Target> | ||||
| 		</Build> | ||||
| 		<Compiler> | ||||
| 			<Add option="-Wall" /> | ||||
| 			<Add option="-fexceptions" /> | ||||
| 		</Compiler> | ||||
| 		<Unit filename="main.cpp" /> | ||||
| 		<Extensions> | ||||
| 			<lib_finder disable_auto="1" /> | ||||
| 		</Extensions> | ||||
| 	</Project> | ||||
| </CodeBlocks_project_file> | ||||
| @ -0,0 +1,89 @@ | ||||
| #include <iostream> | ||||
| #include <vector> | ||||
| #include <cmath> | ||||
| 
 | ||||
| using namespace std; | ||||
| 
 | ||||
| int main() | ||||
| { | ||||
|     const size_t MAX_ASTERISK = 76; | ||||
|     size_t cor, col, H; | ||||
|     int i, j; | ||||
|     double max1, min1; | ||||
| 
 | ||||
|     cerr << "vvedite col-vo col:"; | ||||
|     cin >> col; | ||||
| 
 | ||||
|     vector <double> A(col); | ||||
|     vector <double> B(col); | ||||
| 
 | ||||
|     for(i = 0; i < col; i++) | ||||
|     { | ||||
|         cerr << "A[" << i << "]="; | ||||
|         cin >> A[i]; | ||||
|     } | ||||
| 
 | ||||
|     cerr << "vvedite col-vo cor:"; | ||||
|     cin >> cor; | ||||
| 
 | ||||
|     if (cor == 0) | ||||
|     { | ||||
|         cor = sqrt(col); | ||||
|         if (cor > 25) | ||||
|         { | ||||
|             cor = 1 + log2(col); | ||||
|             cout << "sterg"; | ||||
|         } | ||||
|         else cout << "empirii"; | ||||
|         cout << endl; | ||||
|     } | ||||
| 
 | ||||
|     max1 = A[0]; min1 = A[0]; | ||||
| 
 | ||||
|     for(i = 0; i < col; i++) | ||||
|     { | ||||
|         if (A[i] > max1) max1 = A[i]; | ||||
|         if (A[i] < min1) min1 = A[i]; | ||||
|     } | ||||
| 
 | ||||
|     double cor_size = (max1 - min1)/cor; | ||||
| 
 | ||||
|     for (i = 0; i < col; i++) | ||||
|     { | ||||
|         bool flag = false; | ||||
|         for (j = 0; (j < cor - 1) && !flag; j++) | ||||
|         { | ||||
|            auto L = min1 + j*cor_size; | ||||
|            auto H = min1 + (j+1)*cor_size; | ||||
|            if ((L <= A[i]) && (A[i] < H)) | ||||
|            { | ||||
|                flag = true; | ||||
|                B[j]++; | ||||
|            } | ||||
|         } | ||||
|         if (!flag) B[cor-1]++; | ||||
|     } | ||||
| 
 | ||||
|     int maxb = B[0]; | ||||
| 
 | ||||
|     for (j = 1; j < cor; j++) | ||||
|     { | ||||
|         if (B[j] > maxb) maxb = B[j]; | ||||
|     } | ||||
| 
 | ||||
|     for (j = 0; j < cor; j++) | ||||
|     { | ||||
|         if (maxb > MAX_ASTERISK) | ||||
|         { | ||||
|             H  = MAX_ASTERISK * (static_cast<double>(B[j]) / maxb); | ||||
|         } | ||||
|         else H = B[j]; | ||||
|         if (B[j] < 100) cout << " "; | ||||
|         if (B[j] < 10) cout << " "; | ||||
|         cout << B[j] << "|"; | ||||
|         for (i = 0; i < H; i++) cout << "*"; | ||||
|         cout << endl; | ||||
|     } | ||||
| 
 | ||||
|     return 0; | ||||
| } | ||||
					Загрузка…
					
					
				
		Ссылка в новой задаче