Created
November 13, 2019 18:27
-
-
Save fenske/9f83c3204b23af5cbd080321ecb4dcb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <cmath> | |
| using namespace std; | |
| #define N 3 | |
| // Количество строк матрицы А, сумма элементов каждой из которых меньше нуля. | |
| int main() { | |
| int a[N]; | |
| a[0] = 1; | |
| a[1] = 5; | |
| a[2] = 3; | |
| int c[N]; | |
| c[0] = 4; | |
| c[1] = 2; | |
| c[2] = 6; | |
| // a[0] + c[0]: 1 + 4 = 5 | |
| // (a[0] + c[0]) * (a[1] + c[1]): (1 + 4) * ( 5 + 2) = 35 | |
| // (a[0] + c[0]) * (a[1] + c[1]) * (a[2] + c[2]): (1 + 4) * ( 5 + 2) * (3 + 6) = 315 | |
| int min = a[0] + c[0]; | |
| for (int m = 1; m < N; m++) { | |
| int p = 1; | |
| for (int i = 0; i < N; i++) { | |
| p *= a[i] + c[i]; | |
| } | |
| if (p < min) { | |
| min = p; | |
| } | |
| } | |
| cout << "min = " << min << endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment