Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include <iomanip>
- #include <algorithm>
- using namespace std;
- double fu(double x, double y)
- {
- double U;
- if ((2 * x + y) < 1) {
- U = min(min(pow(x, 2.), pow(y, 2.)), min(x + y, x - y));
- }
- else {
- if ((2 * x + y)<2){
- U = pow(sin(x + y), 2.);
- }
- else {
- U = cos(x - y);
- }
- }
- return U;
- }
- void main()
- {
- setlocale(LC_ALL, "Russian");
- double x, y, U, xn = 0, xk = 5, hx = 1.5, yn = 0, yk = 6, hy = 2, S = 0, P = 1;
- double max = -1E10, xmax, ymax;
- printf("\n Таблца результатов: \n ");
- for (x = xn; x <= xk; x = x + hx) {
- for (y = yn; y <= yk; y = y + hy) {
- U = fu(x, y);
- printf("\n %5.2f %5.2f %5.2f", x, y, U);
- if (U<0){ S = S + U; }
- if (U>3){ P = P*U; }
- if (U>max){ max = U; xmax = x; ymax = y; }
- }
- }
- cout«"cумма отрицательных элементов="«S«endl;
- cout«"произведение значений функции больше 3: P="«P«endl;
- cout«"максимальное значение функции и ее координаты:max="«max«"["«xmax«","«ymax«"]"«endl;
- cout«"положительные значения функции с ее координатами:"«endl;
- for (x = xn; x <= xk; x = x + hx) {
- for (y = yn; y <= yk; y = y + hy) {
- U = fu(x, y);
- if (U>0){
- cout«U«"["«x«","«y«"]"«endl;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement