1、核数据处理课程设计报告通过对C语言的复习和深层得掌握其编程。能够自主地做出以下实验。(一) 计算器制作。1,先建立一个工程,截图如下2,然后制作计算器的界面3,建立类向导写程序如下。void CJmxjisuanqiDlg:Onjia() UpdateData(true);m_Result=m_Firtn+m_Secn;UpdateData(false);void CJmxjisuanqiDlg:Onjian() UpdateData(true);m_Result=m_Firtn-m_Secn;UpdateData(false);void CJmxjisuanqiDlg:Oncheng() U
2、pdateData(true);m_Result=m_Firtn-m_Secn;UpdateData(false);void CJmxjisuanqiDlg:Onchu() UpdateData(true);m_Result=m_Firtn/m_Secn;UpdateData(false);4,运行得到的的界面和结果(二) 按钮实现数据读写。通过对C语言文件相关函数的掌握并熟悉运用可以写出以下实验。创立一个工程文件然后对于按钮键编写属性和建立类向导,建立类向导的程序如下。void CJMXDlg:Onduqushuju() / TODO: Add your control notificati
3、on handler code hereFILE *fp;int datanum=0,data2048;float data_ph2048;int i;int data1,data2;if(fp=fopen(090623.txt,r)=NULL) printf(Cannot open the file.n); exit(0);while(!feof(fp) fscanf(fp,%d %d,&data1,&data2);datadatanum+=data2;fscanf(fp,n); for(i=0;i2048;i+)if(i2045)data_phi=datai;elsedata_phi=(d
4、atai-2+4*datai-1+6*datai+4*datai+1+datai+2)*1.0/16.0;printf(%fn,data_phi);fclose(fp);if(fp=fopen(OUT1.txt,w)=NULL) printf(file open error.n);exit(0);for(i=0;i2048;i+)fprintf(fp,%d %fn,i+1,data_phi);fclose(fp);注意:在编程时要把所给的数据文本文件要在所创立的文件下去编写程序。所给的数据文本文件090623.txt。编译连接。点击读取数据按钮,然后打开生成的OUT1.txt文本文件(四)显示
5、图谱建立工程通过对按钮类向导建立类向导编程1,对读取数据建立类向导。void CxianshitupuDlg:Onduqushuju() / TODO: Add your control notification handler code hereFILE *fp;int datanum=0; int i;int data1,data2;if(fp=fopen(090623.txt,r)=NULL) printf(Cannot open the file.n); exit(0); while(!feof(fp) fscanf(fp,%d %d,&data1,&data2);datadatanu
6、m+=data2;fscanf(fp,n); for(i=0;i2048;i+) if( i2045) data_phi=datai; else data_phi=(datai-2+4*datai-1+6*datai+4*datai+1+datai+2)*1.0/16.0; printf(%d %fn,i+1,data_phi); fclose(fp);if(fp=fopen(out.txt,w)=NULL) printf(file open error.n); exit(0); for(i=0;iGetDC(); pDC-SetMapMode(MM_ANISOTROPIC); CRect r
7、ect; double scale; GetDlgItem(IDC_P1)-GetWindowRect(&rect); scale=25.4*10/pDC-GetDeviceCaps(LOGPIXELSX);CDC MemDC; CBitmap MemBitmap; MemDC.CreateCompatibleDC(NULL); MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height(); MemDC.FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(255,255,255);
8、max=data0;for(int i=1;imax ) max=datai; for ( i = 0;iSetPixel(xViewport,rect.Height()-yViewport-1,RGB(255,0,0); pDC-BitBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY); MemBitmap.DeleteObject(); MemDC.DeleteDC(); pDC-DeleteDC(); 3.对显示五点平滑图谱建立内向导void CXianshitupuDlg:OnXianshiwudian()/ TODO: Add
9、 your control notification handler code heredouble xViewport,yViewport;float max;CWnd *pWnd=GetDlgItem(IDC_P2); CDC *pDC =pWnd-GetDC(); pDC-SetMapMode(MM_ANISOTROPIC); CRect rect; double scale; GetDlgItem(IDC_P2)-GetWindowRect(&rect); scale=25.4*10/pDC-GetDeviceCaps(LOGPIXELSX);CDC MemDC; CBitmap Me
10、mBitmap; MemDC.CreateCompatibleDC(NULL); MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height(); MemDC.FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(255,255,255); max=data_ph0;for(int i=1;imax ) max=data_phi; for ( i = 0;iSetPixel(xViewport,rect.Height()-yViewport-1,RGB(255,0,0); pDC-Bit
11、Blt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY); MemBitmap.DeleteObject(); MemDC.DeleteDC(); pDC-DeleteDC(); 显示图谱的结果(四) 寻峰及道指换算建立工程1. 对左边界建立内向导void CxunfengjidaozhihuansuanDlg:Onzuobianjie() / TODO: Add your control notification handler code hereLButton_Clicked=1;left_flag=1;Left_x=x_old;Left
12、_y=y_old;2.右边界五点寻峰建立内向导void CxunfengjidaozhihuansuanDlg:Onyoubianjiewudianxunfeng() / TODO: Add your control notification handler code hereint i,j,xl,xr,max=0,maxi=0;float newx;CRect rect1;CWnd *pWnd=GetDlgItem(IDC_P1);pWnd-GetWindowRect(rect1);ScreenToClient(&rect1);CDC *pDC =pWnd-GetDC(); RButton_
13、Clicked=1;if(left_flag=1)Right_x=x_old; Right_y=y_old; /GetDlgItem(IDC_P1)-GetWindowRect(&rect1); xl=2048*(Left_x-rect1.left)/rect1.Width(); xr=2048*(Right_x-rect1.left)/rect1.Width(); for(i=xl+2;idatai-2) & (datai-1.0*sqrt(datai)datai+2)for(j=i-2;jmax) max=dataj; maxi=j; m_e3=maxi; UpdateData(false
14、);newx=maxi*rect1.Width()/2048;CDC *pDC =pWnd-GetDC(); CPen lpen(PS_SOLID,1,RGB(0,0,255);CPen* pOldPen = pDC-SelectObject(&lpen); /scale=25.4*10/pDC-GetDeviceCaps(LOGPIXELSX);pDC-MoveTo(newx,0); pDC-LineTo(newx,rect1.Height();lpen.DeleteObject(); RButton_Clicked=0;LButton_Clicked=0;3.左道址建立内向导void Cx
15、uanfengjidaozhihuansuanDlg:OnZuodaozhi() / TODO: Add your control notification handler code hereCRect rect1;int chx; CWnd *pWnd=GetDlgItem(IDC_P1);pWnd-GetWindowRect(rect1);ScreenToClient(&rect1);chx=2048*(x_old-rect1.left)/rect1.Width();m_e1=chx;UpdateData(false);4.右道指建立内向导void Cxunfengjidaozhihuan
16、suanDlg:OnYoudaozhi() / TODO: Add your control notification handler code hereCRect rect1;int chx; CWnd *pWnd=GetDlgItem(IDC_P1);pWnd-GetWindowRect(rect1);ScreenToClient(&rect1);chx=2048*(x_old-rect1.right)/rect1.Width();m_e2=chx;UpdateData(false);显示图谱的结果五。求峰面积建立工作空间1.读取数据,建立内向导void CqiufengmianjiDlg
17、:OnDuqushuju() / TODO: Add your control notification handler code hereFILE *fp;int datanum=0; int i;int data1,data2;if(fp=fopen(090623.txt,r)=NULL) printf(Cannot open the file.n); exit(0); while(!feof(fp) fscanf(fp,%d %d,&data1,&data2);datadatanum+=data2;fscanf(fp,n); for(i=0;i2048;i+) if( i2045) da
18、ta_phi=datai; else data_phi=(datai-2+4*datai-1+6*datai+4*datai+1+datai+2)*1.0/16.0; printf(%d %fn,i+1,data_phi); fclose(fp); if(fp=fopen(out.txt,w)=NULL) printf(file open error.n); exit(0); for(i=0;iGetDC(); pDC-SetMapMode(MM_ANISOTROPIC); CRect rect; double scale; GetDlgItem(IDC_P1)-GetWindowRect(&
19、rect);scale=25.4*10/pDC-GetDeviceCaps(LOGPIXELSX);CDC MemDC;CBitmap MemBitmap; MemDC.CreateCompatibleDC(NULL); MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height() ; MemDC.FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(255,255,255); max=data0;for(int i=1;imax)max=datai; for(i=0;iSetPixe
20、l(xViewport,rect.Height()-yViewport-1,RGB(255,0,0); pDC-BitBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY); MemBitmap.DeleteObject(); MemDC.DeleteDC();pDC-DeleteDC;3.显示五点平滑图谱。建立内向导void CqiufengmianjiDlg:Onxianshiwudianpinghuatupu() / TODO: Add your control notification handler code heredouble
21、 xViewport,yViewport;float max;CWnd *pWnd=GetDlgItem(IDC_P2);CDC *pDC=pWnd-GetDC();pDC-SetMapMode(MM_ANISOTROPIC);CRect rect;double scale;GetDlgItem(IDC_P2)-GetWindowRect(&rect);scale=25.4*10/pDC-GetDeviceCaps(LOGPIXELSX);CDC MemDC;CBitmap MemBitmap;MemDC.CreateCompatibleDC(NULL);MemBitmap.CreateCom
22、patibleBitmap(pDC,rect.Width(),rect.Height();MemDC.FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(255,255,255);max=data_ph0;for(int i=1;imax)max=data_phi;for(i=0;iSetPixel(xViewport,rect.Height()-yViewport-1,RGB(255,0,0);pDC-BitBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY);MemBitmap.Delet
23、eObject();MemDC.DeleteDC();pDC-DeleteDC();void CqiufengmianjiDlg:OnLButtonUp(UINT nFlags, CPoint point) / TODO: Add your message handler code here and/or call default/ TODO: Add your message handler code here and/or call defaultCRect rect1;CWnd *pWnd=GetDlgItem(IDC_P1);pWnd-GetWindowRect(rect1);Scre
24、enToClient(&rect1);CDC *pDC =pWnd-GetDC(); if (rect1.PtInRect(point) pDC-MoveTo(point.x-rect1.left,0); pDC-LineTo(point.x-rect1.left,rect1.Height();if(LButton_Clicked=0)CPen lpen(PS_SOLID, 1, RGB(255,255,255);CPen* pOldPen = pDC-SelectObject(&lpen); pDC-MoveTo(x_old-rect1.left,0); pDC-LineTo(x_old-r
25、ect1.left,rect1.Height();lpen.DeleteObject(); x_old=point.x;y_old=point.y;elseLButton_Clicked=0;x_old=point.x;y_old=point.y;CDialog:OnLButtonUp(nFlags, point);4.左边界,建立内向导void CqiufengmianjiDlg:OnZuobianjie() / TODO: Add your control notification handler code hereLButton_Clicked=1;left_flag=1;Left_x=
26、x_old;Left_y=y_old;5.五点寻峰,建立类向导void CqiufengmianjiDlg:OnWudianxunfeng() / TODO: Add your control notification handler code hereint i,j,xl,xr,max=0,maxi=0;float newx;CRect rect1;CWnd *pWnd=GetDlgItem(IDC_P1);pWnd-GetWindowRect(rect1);ScreenToClient(&rect1);CDC *pDC =pWnd-GetDC(); RButton_Clicked=1;if
27、(left_flag=1)Right_x=x_old; Right_y=y_old; /GetDlgItem(IDC_P1)-GetWindowRect(&rect1); xl=2048*(Left_x-rect1.left)/rect1.Width(); xr=2048*(Right_x-rect1.left)/rect1.Width(); for(i=xl+2;idatai-2) & (datai-1.0*sqrt(datai)datai+2)for(j=i-2;jmax) max=dataj; maxi=j; m_e3=maxi; UpdateData(false);newx=maxi*
28、rect1.Width()/2048;CDC *pDC =pWnd-GetDC(); CPen lpen(PS_SOLID,1,RGB(0,0,255);CPen* pOldPen = pDC-SelectObject(&lpen); /scale=25.4*10/pDC-GetDeviceCaps(LOGPIXELSX);pDC-MoveTo(newx,0); pDC-LineTo(newx,rect1.Height();lpen.DeleteObject(); RButton_Clicked=0;LButton_Clicked=0;6.左道址,建立类向导void Cqiufengmianj
29、iDlg:OnZuodaozhi() / TODO: Add your control notification handler code hereCRect rect1;int chx; CWnd *pWnd=GetDlgItem(IDC_P1);pWnd-GetWindowRect(rect1);ScreenToClient(&rect1);chx=2048*(x_old-rect1.left)/rect1.Width();m_e1=chx;UpdateData(false);7.右道址,建立类向导void CShiyanDlg:OnYoudaozhi() / TODO: Add your
30、 control notification handler code hereCRect rect1;int chx; CWnd *pWnd=GetDlgItem(IDC_P1);pWnd-GetWindowRect(rect1);ScreenToClient(&rect1);chx=2048*(x_old-rect1.right)/rect1.Width();m_e2=chx;UpdateData(false);8.求峰面积void CqiufengmianjiDlg:Onjqiufengmianji() / TODO: Add your control notification handl
31、er code hereint i,j,xl,xr,max=0,maxi=0;float newx;int L,R;long double S=0;long double B=0,A=0;CRect rect1;CWnd *pWnd=GetDlgItem(IDC_P1);pWnd-GetWindowRect(rect1);ScreenToClient(&rect1);CDC *pDC =pWnd-GetDC(); RButton_Clicked=1;if(left_flag=1)Right_x=x_old; Right_y=y_old; xl=2048*(Left_x-rect1.left)/
32、rect1.Width(); xr=2048*(Right_x-rect1.left)/rect1.Width(); for(i=xl+2;idatai-2) & (datai-1.0*sqrt(datai)datai+2)for(j=i-2;jmax) max=dataj; maxi=j; /*/int l,r;for(l=1;l=(datamaxi-l+1.5*sqrt(datamaxi-l) L=maxi-l; goto LL1;L=xl;LL1:for(r=1;r=(datamaxi+r+1.5*sqrt(datamaxi+r) R=maxi+r; goto LL2; R=xr;LL2: for(i=L;iGetDC(); CPen lpen(PS_SOLID, 1, RGB(0,0,255);CPen* pOldPen = pDC-SelectObject(&lpen); /scale=25.4*10/pDC-GetDeviceCaps(LOGPIXELSX);pDC-MoveTo(newx,0); pDC-LineTo(newx,rect1.Height();lpen.DeleteObject(); RButton_Clicked=0;LButton_Clicked=0;结果显示
版权声明:以上文章中所选用的图片及文字来源于网络以及用户投稿,由于未联系到知识产权人或未发现有关知识产权的登记,如有知识产权人并不愿意我们使用,如有侵权请立即联系:2622162128@qq.com ,我们立即下架或删除。
Copyright© 2022-2024 www.wodocx.com ,All Rights Reserved |陕ICP备19002583号-1
陕公网安备 61072602000132号 违法和不良信息举报:0916-4228922