数值分析课程的实验报告

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1实验报告实验课程:学生姓名:学号:专业班级:2012年6月8日2目录---(1)用C语言或C++编程显示字母T与5...................................................3---(2)原子弹爆炸能量估计...............................................................................11---(3)城市水管埋多深.......................................................................................15---(4)实现PageRank算法.................................................................................183计算机系数值分析实验报告---(1)用C语言或C++编程显示字母T与5学生姓名:学号:专业班级:实验类型:■验证□综合□设计□创新实验日期:2012/4/20实验成绩:一、实验目的用C语言或C++编程显示字母T与5。二、实验基本原理和内容Bezier曲线生成:1、确定曲线的阶次;2、计算Bernstein基函数的表达式:B0,3(t)﹦(1-t)3;B1,3(t)﹦3t(1-t)2;B2,3(t)﹦3t2(1-t);B3,3(t)﹦t33、把Bezier曲线中的Pk写成分量坐标的形式4、确定一合适的步长;控制t从0到1变化,求出一系列(x,y)坐标点;将其用小线段顺序连接起来。三、算法分析对于二维平面的情况,只有x,y坐标分量,可以给出四点三次Bezier曲线如下的算法描述:输入:阶次,3;控制顶点:4个,(x0,y0),…,(x3,y3)beginx=x0y=y0moveto(x,y)fort﹦0to1steptx﹦B0,3(t)x0﹢B1,3(t)x1﹢B2,3(t)x2﹢B3,3(t)x3y﹦B0,3(t)y0﹢B1,3(t)y1﹢B2,3(t)y2﹢B3,3(t)y3lineto(x,y)endforend三次Bezier曲线例子:设在平面上给定的7个控制点坐标分别为:A(100,300),B(120,200),C(220,200),D(270,100),E(370,100),F(420,200),G(420,300)。画出其曲线。nktttknknttCtBknkknkknnk,,1,0]1,0[)1()!(!!)1()(,4四、实验内容和过程代码://xx.cpp:Definestheentrypointfortheapplication.//#includestdafx.h#includeresource.h#defineMAX_LOADSTRING100//GlobalVariables:HINSTANCEhInst;//currentinstanceTCHARszTitle[MAX_LOADSTRING];//ThetitlebartextTCHARszWindowClass[MAX_LOADSTRING];//Thetitlebartext//Fowarddeclarationsoffunctionsincludedinthiscodemodule:ATOMMyRegisterClass(HINSTANCEhInstance);BOOLInitInstance(HINSTANCE,int);LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);LRESULTCALLBACKAbout(HWND,UINT,WPARAM,LPARAM);//===================================================//===========要我们加的数据================int5xT[15][4]={237,237,237,237,237,237,226,143,143,143,143,143,143,143,435,435,435,435,435,435,435,353,339,339,339,339,339,339,339,507,529,552,552,552,576,576,576,576,570,570,570,570,6,6,6,6,0,0,0,0,24,24,24,48,71,183,183,183,237,237};intyT[15][4]={620,620,120,120,120,35,24,19,19,19,0,0,0,0,0,0,0,0,19,19,19,23,36,109,109,108,620,620,620,620,602,492,492,492,492,492,492,492,662,662,662,662,662,662,662,662,492,492,492,492,492,492,492,602,620,620,620,620,620,620};intx5[21][4]={149,149,149,345,345,361,356,368,368,406,368,406,406,397,406,397,397,382,372,351,351,351,351,142,142,33,142,33,33,32,32,32,32,32,35,44,44,74,109,149,149,269,324,324,324,324,264,185,185,165,149,119,119,86,65,42,42,14,0,0,0,0,46,121,121,205,282,333,333,378,399,399,399,399,381,333,333,288,232,112,112,112,149,149};inty5[21][4]={597,597,597,597,597,597,599,606,606,695,606,695,695,702,695,702,702,681,676,676,676,676,676,676,676,439,676,439,439,438,436,434,434,428,426,426,426,426,420,408,408,372,310,208,208,112,37,37,37,37,44,66,66,90,99,99,99,99,87,62,62,24,0,0,0,0,27,78,78,123,180,256,256,327,372,422,422,468,491,512,512,512,597,597};//====================================================intAPIENTRYWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow){//TODO:Placecodehere.MSGmsg;HACCELhAccelTable;//InitializeglobalstringsLoadString(hInstance,IDS_APP_TITLE,szTitle,MAX_LOADSTRING);LoadString(hInstance,IDC_XX,szWindowClass,MAX_LOADSTRING);MyRegisterClass(hInstance);//Performapplicationinitialization:if(!InitInstance(hInstance,nCmdShow)){returnFALSE;}hAccelTable=LoadAccelerators(hInstance,(LPCTSTR)IDC_XX);//Mainmessageloop:6while(GetMessage(&msg,NULL,0,0)){if(!TranslateAccelerator(msg.hwnd,hAccelTable,&msg)){TranslateMessage(&msg);DispatchMessage(&msg);}}returnmsg.wParam;}////FUNCTION:MyRegisterClass()////PURPOSE:Registersthewindowclass.////COMMENTS:////Thisfunctionanditsusageisonlynecessaryifyouwantthiscode//tobecompatiblewithWin32systemspriortothe'RegisterClassEx'//functionthatwasaddedtoWindows95.Itisimportanttocallthisfunction//sothattheapplicationwillget'wellformed'smalliconsassociated//withit.//ATOMMyRegisterClass(HINSTANCEhInstance){WNDCLASSEXwcex;wcex.cbSize=sizeof(WNDCLASSEX);wcex.style=CS_HREDRAW|CS_VREDRAW;wcex.lpfnWndProc=(WNDPROC)WndProc;wcex.cbClsExtra=0;wcex.cbWndExtra=0;wcex.hInstance=hInstance;wcex.hIcon=LoadIcon(hInstance,(LPCTSTR)IDI_XX);wcex.hCursor=LoadCursor(NULL,IDC_ARROW);wcex.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);wcex.lpszMenuName=(LPCSTR)IDC_XX;wcex.lpszClassName=szWindowClass;wcex.hIconSm=LoadIcon(wcex.hInstance,(LPCTSTR)IDI_SMALL);7returnRegisterClassEx(&wcex);}////FUNCTION:InitInstance(HANDLE,int)////PURPOSE:Savesinstancehandleandcreatesmainwindow////COMMENTS:////Inthisfunction,wesavetheinstancehandleinaglobalvariableand//createanddisplaythemainprogramwindow.//BOOLInitInstance(HINSTANCEhInstance,intnCmdShow){HWNDhWnd;hInst=hInstance;//StoreinstancehandleinourglobalvariablehWnd=CreateWindow(szWindowClass,szTitle,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL);if(!hWnd){returnFALSE;}ShowWindow(hWnd,nCmdShow);UpdateWindow(hWnd);returnTRUE;}////FUNCTION:WndProc(HWND,unsigned,WORD,LONG)////PURPOSE:Processesmessagesforthemainwindow.////WM_COMMAND-processtheapplicationmenu//WM_PAINT-Paintthemainwindow//WM_DESTROY-postaquitmessagea

1 / 23
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功