// Menu.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include using namespace std; #include "WString.h" #include "math.h" #include "DVector.h" double f_exp(double x, double epsi) { double stx,fakt,ex; int i; stx=x; fakt=1; ex=1; i=1; while (stx/fakt>=epsi) { ex=ex+stx/fakt; i++; stx=stx*x; fakt=fakt*i; } return ex; } class WMenuFunction { public: WMenuFunction(){name = "default";}; virtual void execute(bool *exit){}; virtual void printf_name(){name.m_printf();}; virtual void set_name(WString str){name = str;} private: WString name; }; class w_exp: public WMenuFunction { public: w_exp(){name = "e^x at point"; set_name(name);} void execute(bool *exit) { system("cls"); printf_name(); cout<<"------------------"<>x; cout<<"Enter determ value"<>epsi; cout<<"Result is: "<>xs; cout<<"Enter end x"<>xe; cout<<"Enter step size"<>step; double x,y,epsi; cout<<"Enter determ value"<>epsi; cout<<"Result is: "<>x; cout<<"Result is: "<>xs; cout<<"Enter end x"<>xe; cout<<"Enter step size"<>step; double x,y; cout<<"Result is: "<printf_name(); //printf("\n"); printf("--------------------------------------------------------------------------\n"); if(enter){obj[i]->execute(&EXIT); enter = false; redraw = true;}else{redraw = false;} }else{printf("\n"); obj[i]->printf_name(); printf("\n");} } if((!EXIT)&&(!redraw)) { key = _getch(); if ((key == 0x50)&&(selected < obj.GetSize()-2)) selected++; if ((key == 0x48)&&(selected > 0)) selected--; if (key == 13){enter = true;} } } } private: WString name; Vector obj; int key,selected,redraw; bool enter,EXIT; }; void main() { setlocale(LC_ALL,".1251"); int h = 3; w_sqrt fDoubleUpX; w_sqrt_r fDoubleUpXrange; w_exp fExpX; w_exp_r fExpXrange; w_iext fExit; h = 3; WMenuFunction** fExpXmenu=new WMenuFunction*[h]; fExpXmenu[0]=&fExpX; fExpXmenu[1]=&fExpXrange; fExpXmenu[2]=&fExit; WMenu MenuExponenta(h,fExpXmenu,"Exponenta"); h = 3; WMenuFunction** fMnchXmenu=new WMenuFunction*[h]; fMnchXmenu[0]=&fDoubleUpX; fMnchXmenu[1]=&fDoubleUpXrange; fMnchXmenu[2]=&fExit; WMenu MenuPolinom(h,fMnchXmenu,"Polinom"); h = 3; WMenuFunction** Menu1_Func=new WMenuFunction*[h]; Menu1_Func[0]=&MenuPolinom; Menu1_Func[1]=&MenuExponenta; Menu1_Func[2]=&fExit; WMenu Menu(h,Menu1_Func,"Welcome to Function Culc"); bool ex=false; Menu.execute(&ex); }