最优化理论作业文档格式.docx
《最优化理论作业文档格式.docx》由会员分享,可在线阅读,更多相关《最优化理论作业文档格式.docx(20页珍藏版)》请在冰豆网上搜索。
#endif
/////////////////////////////////////////////////////////////////////////////
//CXixiaozheView
IMPLEMENT_DYNCREATE(CXixiaozheView,CView)
BEGIN_MESSAGE_MAP(CXixiaozheView,CView)
//{{AFX_MSG_MAP(CXixiaozheView)
ON_COMMAND(ID_xdfqj,Onxdfqj)
ON_COMMAND(ID_hjfgf,Onhjfgf)
//}}AFX_MSG_MAP
//Standardprintingcommands
ON_COMMAND(ID_FILE_PRINT,CView:
:
OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT,CView:
ON_COMMAND(ID_FILE_PRINT_PREVIEW,CView:
OnFilePrintPreview)
END_MESSAGE_MAP()
//CXixiaozheViewconstruction/destruction
intxm0;
doubleH;
doubleh0,A0,B0,a[4],x[3][4],f[4],s[3],y[50];
CXixiaozheView:
CXixiaozheView()
{
xm0=0;
H=26;
h0=0.4368;
x[1][0]=0,x[2][0]=1;
s[1]=-1;
s[2]=4;
s[1]=s[1]/sqrt(s[1]*s[1]+s[2]*s[2]);
s[2]=s[2]/sqrt(s[1]*s[1]+s[2]*s[2]);
}
~CXixiaozheView()
BOOLCXixiaozheView:
PreCreateWindow(CREATESTRUCT&
cs)
//TODO:
ModifytheWindowclassorstylesherebymodifying
//theCREATESTRUCTcs
returnCView:
PreCreateWindow(cs);
//CXixiaozheViewdrawing
voidCXixiaozheView:
OnDraw(CDC*pDC)
CXixiaozheDoc*pDoc=GetDocument();
ASSERT_VALID(pDoc);
CRectrect;
CFontfnBig;
fnBig.CreatePointFont(300,"
Arial"
pDC);
CFont*pOldFont=pDC->
SelectObject(&
fnBig);
kk(pDC,RGB(225,225,225),(0,0),1000,800);
pDC->
SetMapMode(MM_LOMETRIC);
GetClientRect(&
rect);
SetViewportOrg(rect.right*2/3,rect.bottom*3/4);
SetBkMode(TRANSPARENT);
switch(xm0)
{
case0:
pDC->
TextOut(int(-30*H),int(30*H),"
VisalC++作业一"
);
break;
case1:
TextOut(int(-40*H),int(34*H),"
进退法按给定方向确定下单峰区间"
zbx(pDC);
xdfqj(pDC);
sjsc(pDC);
case2:
进退法-黄金分割法"
hjfg(pDC);
}
//CXixiaozheViewprinting
OnPreparePrinting(CPrintInfo*pInfo)
//defaultpreparation
returnDoPreparePrinting(pInfo);
OnBeginPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)
addextrainitializationbeforeprinting
OnEndPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)
addcleanupafterprinting
//CXixiaozheViewdiagnostics
AssertValid()const
CView:
AssertValid();
Dump(CDumpContext&
dc)const
Dump(dc);
CXixiaozheDoc*CXixiaozheView:
GetDocument()//non-debugversionisinline
ASSERT(m_pDocument->
IsKindOf(RUNTIME_CLASS(CXixiaozheDoc)));
return(CXixiaozheDoc*)m_pDocument;
#endif//_DEBUG
//CXixiaozheViewmessagehandlers
kk(CDC*pDC,COLORREFcol,CPointpoint,intdx,intdy)
CBrushnewBrush(col);
CBrush*poldBrush;
poldBrush=pDC->
newBrush);
FillRect(CRect(point.x,point.y,point.x+dx,point.y+dy),&
SelectObject(poldBrush);
newBrush.DeleteObject();
Line(CDC*pDC,doublex1,doubley1,doublex2,doubley2,intsiw,COLORREFcol)
CPensiPen;
CPen*pOldPen;
siPen.CreatePen(PS_SOLID,siw,col);
pOldPen=pDC->
siPen);
MoveTo(int(H*x1),int(H*y1));
LineTo(int(H*x2),int(H*y2));
SelectObject(pOldPen);
siPen.DeleteObject();
zbx(CDC*pDC)
intj;
doublexl,yl,ds;
doublex1,x2,y1,y2;
CStringsc;
Line(pDC,-52,0,22,0,4,RGB(100,100,100));
TextOut(int(H*21),50,"
a"
xl=0;
ds=0;
sc.Format("
%2.1f"
ds);
TextOut(5,-10,sc,strlen(sc));
for(j=0;
j<
4;
j++)
xl+=5;
ds+=0.2;
Line(pDC,xl,0,xl,0.5,1,RGB(0,0,0));
sc.Format("
%3.1f"
TextOut(int(H*xl)-20,-10,sc,strlen(sc));
10;
xl-=5;
ds-=0.2;
Line(pDC,0,-10,0,33,4,RGB(100,100,100));
TextOut(30,int(H*34)+10,"
f(a)"
yl=0;
ds=0;
6;
yl+=5;
ds+=1;
Line(pDC,0,yl,0.5,yl,1,RGB(0,0,0));
TextOut(20,int(H*yl)+10,sc,strlen(sc));
xl=0.6;
105;
x1=x[1][0]+xl*s[1];
x2=x[2][0]+xl*s[2];
y1=mbF(x1,x2);
xl-=0.025;
x2=x[2]