https://pastein.ru/t/t6

  скопируйте уникальную ссылку для отправки


#include <windows.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string.h>
#include <windowsx.h>
#include <stdio.h>

#define ID_EDIT 1
#define ID_EDIT1 2
#define ID_EDIT2 3

#define ID_LISTBOX 4
#define ID_BUTTMINY 5
#define ID_BUTTMAXY 12
#define ID_BUTSRY 7
#define ID_BUTRES 11

#define ID_EDIT3 8
#define ID_EDIT4 9
#define ID_EDIT5 10

double x, y;
double cs; 
double a, b, d;
double min, max;

double	sry;
double viv;

char lox[100] = {"Нет значения"};
char bla[10];
char blya[10];
char xui[10];

HWND hlist;
HDC hdc;
HINSTANCE hInst;
PAINTSTRUCT ps;

HWND hedit;
HWND hedit1;
HWND hedit2;
HWND hedit3;
HWND hedit4;
HWND hedit5;

HWND hButton1, hButton2, hButton3, hButton4;


HWND hButton[3];

void newbottonz(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	hedit = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 240, 10, 270, 30, hwnd, (HMENU)ID_EDIT, NULL, NULL);//ЕДИТ ДЛЯ ВВОДА MIN X
	hedit1 = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 240, 45, 270, 30, hwnd, (HMENU)ID_EDIT1, NULL, NULL);//ЕДИТ ДЛЯ ВВОДА MAX X
	hedit2 = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 240, 80, 270, 30, hwnd, (HMENU)ID_EDIT2, NULL, NULL);//ЕДИТ ДЛЯ ВВОДА ШКОЛИЧЕСТВА ШАГОВ X
	
	hlist = CreateWindow("listbox", "", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | WS_VSCROLL | WS_HSCROLL| LBS_NOTIFY, 10, 160, 500, 250, hwnd, (HMENU)ID_LISTBOX , NULL, NULL);
	hButton1 = CreateWindow("button", "Узнать min Y", WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 420, 150, 50, hwnd, (HMENU)ID_BUTTMINY, NULL, NULL);
	hButton2 = CreateWindow("button", "Узнать max Y", WS_CHILD | WS_VISIBLE | WS_BORDER, 180, 420, 160, 50, hwnd, (HMENU)ID_BUTTMAXY, NULL, NULL);
	hButton3 = CreateWindow("button", "Узнать средний Y", WS_CHILD | WS_VISIBLE | WS_BORDER, 360, 420, 150, 50, hwnd, (HMENU)ID_BUTSRY, NULL, NULL);
	hButton4 = CreateWindow("button", "ВЫВЕСТИ РЕЗУЛЬТАТ", WS_CHILD | WS_VISIBLE | WS_BORDER, 20, 110, 200, 40, hwnd, (HMENU)ID_BUTRES, NULL, NULL);
	
	hedit3 = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 470, 150, 30, hwnd, (HMENU)ID_EDIT3, NULL, NULL); //ЕДИТ ДЛЯ ВЫВОДА min Y
	hedit4 = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 180, 470, 160, 30, hwnd, (HMENU)ID_EDIT4, NULL, NULL);//ЕДИТ ДЛЯ ВЫВОДА max Y
	hedit5 = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 360, 470, 150, 30, hwnd, (HMENU)ID_EDIT5, NULL, NULL);//ЕДИТ ДЛЯ ВЫВОДА средний Y Y
}


LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);


/* The 'main' function of Win32 GUI programs: this is where execution starts */
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	WNDCLASSEX wc; /* A properties struct of our window */
	HWND hwnd; /* A 'HANDLE', hence the H, or a pointer to our window */
	MSG msg; /* A temporary location for all messages */

	/* zero out the struct and set the stuff we want to modify */
	memset(&wc,0,sizeof(wc));
	wc.cbSize		 = sizeof(WNDCLASSEX);
	wc.lpfnWndProc	 = WndProc; /* This is where we will send messages to */
	wc.hInstance	 = hInstance;
	wc.hCursor		 = LoadCursor(NULL, IDC_ARROW);
	
	/* White, COLOR_WINDOW is just a #define for a system color, try Ctrl+Clicking it */
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszClassName = "WindowClass";
	wc.hIcon		 = LoadIcon(NULL, IDI_APPLICATION); /* Load a standard icon */
	wc.hIconSm		 = LoadIcon(NULL, IDI_APPLICATION); /* use the name "A" to use the project icon */

	if(!RegisterClassEx(&wc)) {
		MessageBox(NULL, "Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
		return 0;
	}

	hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass","Caption",WS_VISIBLE|WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, /* x */
		CW_USEDEFAULT, /* y */
		640, /* width */
		600, /* height */
		NULL,NULL,hInstance,NULL);

	if(hwnd == NULL) {
		MessageBox(NULL, "Window Creation Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
		return 0;
	}

	/*
		This is the heart of our program where all input is processed and 
		sent to WndProc. Note that GetMessage blocks code flow until it receives something, so
		this loop will not produce unreasonably high CPU usage
	*/
	while(GetMessage(&msg, NULL, 0, 0) > 0) { /* If no error is received... */
		TranslateMessage(&msg); /* Translate key codes to chars if present */
		DispatchMessage(&msg); /* Send it to WndProc */
	}
	return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
	switch(Message) {
		
		case WM_CREATE:{
			newbottonz(hwnd,Message,wParam,lParam);
			break;
		}
		
		case WM_PAINT:{ //ппрорисовка текста
		    hdc = BeginPaint(hwnd, &ps); // начало перерисовки
		    TextOut(hdc, 25, 15, "Введите начало диапозона :", 26); // вывод текстовых сообщений
		    TextOut(hdc, 30, 50, "Введите конец диапозона :", 26);
		    TextOut(hdc, 45, 85, "Введите число шагов :", 22);
		    EndPaint(hwnd, &ps); // конец перерисовки
		    break;
		}
		
		case WM_COMMAND:{
		
			if ((HWND)lParam ==  hButton4){
				
			SendMessage(hlist, LB_RESETCONTENT, 0, 0);
			
			char number1[10];
            Edit_GetLine(hedit,0,number1,10);
            a = atof(number1);
            
            Edit_GetLine(hedit1,0,number1,10);
            b = atof(number1);
            
            Edit_GetLine(hedit2,0,number1,10);
            cs = atof(number1);
            
            d = (b - a) / cs;
            
            y = ((a*a+pow(2.3,a))/(a*+log(pow(a,3)+1)))*(a+cos(a));
			min = y;
			max = y;
            
			for (x = a;  x<b; x+=d)	{
				
				if (x>0){
				
				char itogx[100] = {"x = "};
				char resultx[100]={0};
				sprintf(resultx,"%lf",x);
				strcat (itogx,resultx);
				
				y = ((x*x+pow(2.3,x))/(x*+log(pow(x,3)+1)))*(x+cos(x)); 
				
				char itogy[100] = {" y = "};
				char resulty[100]={0};
				sprintf(resulty,"%lf",y);
				strcat (itogy,resulty);
				
				strcat (itogx,itogy);
				
				SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM) itogx);
					
				if (y>max) {
					max = y;
				}
	
				if (y<min) {
					min = y;
				}
				
				sry += y;
				
				}else if(x<=0){
					SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM) lox);
				}	
					
			}
				viv = sry/cs;
			
			}
			
			if ((HWND)lParam ==  hButton1){
			
				sprintf(bla,"%lf",min);
				SetWindowText(hedit3,bla);
			
			}
			
			if ((HWND)lParam ==  hButton2){
			
				sprintf(blya,"%lf",max);
				SetWindowText(hedit4,blya);
			
			}
			
			if ((HWND)lParam ==  hButton3){
			
				sprintf(xui,"%lf",viv);
				SetWindowText(hedit5,xui);
			
			}
				
		break;
		}
		
		/* Upon destruction, tell the main thread to stop */
		case WM_DESTROY: {
			PostQuitMessage(0);
			break;
		}
		
		/* All other messages (a lot of them) are processed using default procedures */
		default:
			return DefWindowProc(hwnd, Message, wParam, lParam);
	}
	return 0;
}