计算机实习内容要求_第1页
计算机实习内容要求_第2页
计算机实习内容要求_第3页
计算机实习内容要求_第4页
计算机实习内容要求_第5页
已阅读5页,还剩23页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、北京邮电大学计算机实习 指导教师:苗建松第 PAGE 28页*北京邮电大学信息与通信工程学院 TITLE * MERGEFORMAT 计算机实习内容要求 SUBJECT * MERGEFORMAT 信息与通信工程学院2010级2011年 8月22日实习要求1基本要求1.1、内容要求作品的内容可以是下面4种中的任意一种:可以制作一个小游戏,比如俄罗斯方块、贪吃蛇、时钟、投筛子等;可以制作一个课件,比如模拟汉诺塔游戏的过程;可以制作一个管理系统,比如学生成绩管理、学生基本信息管理等;其它你认为有兴趣的作品。1.2、作品功能要求 基本要求: 能够应用文件流进行磁盘文件的读写:比如游戏分数的保存等能够

2、应用面向对象的设计思想和方法能够使用多文件结构能够播放音频文件,增强游戏的效果2可选课题鉴于部分同学对于Windows编程非常感兴趣,并且C+基础较好,可以1-2人组成一个课题小组,尝试完成下面的课题(选作可选课题中的任何一个,就不需要在做基本要求中的内容了)。同学们分组作自选课题必须跟老师协商并说明思路,经老师允许后方可开始进行。2.1、完成一个简单计算器简单计算器的界面如图3所示,功能可以参见Windows操作系统的附件中的计算器的功能,能够完成基本的算术运算。图1 简单计算器研究步骤:学习Windows编程框架,了解消息机制学习各种控件的使用,尤其是对话框、按钮、编辑框等学习菜单的使用如

3、果时间允许,可以将简单计算器,扩展为如图4所示的科学计算器。图2 科学计算器2.2、完成一个简单的信息管理系统简单的信息管理系统主要能够完成对信息的读取、增、删、改、查、排序、保存等功能,比如一个简单学生信息管理系统界面如图4所示,基本功能如下:(1)读取文件中的学生信息,能够按照学生类别显示;(2)能够增加、删除、修改学生信息(3)能够按照学号精确查询学生信息(4)能够统计不同类别、不同性别的学生人数(5)更新后的学生信息数据保存在文件中图3 简单学生管理系统研究步骤:学习Windows编程框架,了解消息机制学习各种控件的使用,尤其是对话框、按钮、编辑框等学习菜单的使用学习IO流的使用可以对

4、各种信息进行管理,比如学生成绩管理系统、通讯录、图书管理系统等2.3、完成一个画图软件简单的画图软件的形式和功能可以参考Windows操作系统中“附件”里的画图软件,如图6所示。图4 画图软件该软件能够完成如下基本功能:(1)能够绘制直线、曲线;(2)能够绘制各种形状,比如矩形、椭圆形等(3)能够绘制各种实心形状,比如实心矩形、实心椭圆等(4)能够添加文字(5)能够设置不同的绘制颜色研究步骤:学习使用单文档的(Single document)程序结构学习使用MFC中CDC类系列的使用,包括CPen类、CBrush类等学习使用鼠标消息处理函数的使用有能力的同学可以扩展画图软件的功能,比如能够显示

5、磁盘上已有的图片文件、能够具备“橡皮擦”的功能,进行擦除、能够保存绘制后的图形等等2.4、自选题目学生根据自身的情况,可以自由选择感兴趣的题目,要求一要写出具体的想法以及预期完成的结果,二要征得实验教师的同意。下面给出一些题目可供参考。可以实现一个简单的Windows游戏,比如:碰碰球游戏,游戏者可以控制木板的左右移动,迎接下落的小球,小球与模板碰撞后弹起,反复运行,直到小球下落后木板无法接起,游戏结束。参考程序如图7所示。图6 碰碰球游戏可以实现Josephus问题的求解,Josephus问题是:n个小孩围成一圈,任意假定一个数m,从第一个小孩起,顺时针方向数,每数到第m个的小孩时,该小孩便

6、离开。小孩不断离开,圈子中的人数不断减少,最后一个离开的小孩是胜利者,请问最后一个离开的小孩的编号?实现可参考程序如图8所示。图7 Josephus问题的求解可以学习使用OpenGL等工具库实现一个动画制作,题目任意。可以学习数据库的使用,完成一个基于数据库的信息管理系统。可以学习Socket类的使用,完成一个基于网络的应用,比如一个即时消息系统、文件传输系统等。可以学习如何实现一个屏幕保护程序可以学习任何你感兴趣的相关程序设计的知识,完成一个完整的作品。参考资料可以参考以下资料。vc经典教程.chm 电子版C+到Visual C+ 6.0精彩100例,应甫臣、刘迎辉编,电脑爱好者杂志出版社,

7、2001年Visual C+ 课程设计案例精选,严华峰等编著,中国水利水电出版社,2002年附件1文件ColorConsole.h#include #include using namespace std;HANDLE initiate();BOOL textout(HANDLE hOutput,int x,int y,WORD wColors,int nColors,LPTSTR lpszString);附件2文件colorConsole.cpp#include colorConsole.hHANDLE initiate()HANDLE hOutput; hOutput = GetStdHa

8、ndle(STD_OUTPUT_HANDLE);return hOutput;BOOL textout(HANDLE hOutput,int x,int y,WORD wColors,int nColors,LPTSTR lpszString) DWORD cWritten; BOOL fSuccess; COORD coord; coord.X = x; / start at first cell coord.Y = y; / of first row fSuccess = WriteConsoleOutputCharacter( hOutput, / screen buffer handl

9、e lpszString, / pointer to source string lstrlen(lpszString), / length of string coord, / first cell to write to &cWritten); / actual number written if (! fSuccess) couterror:WriteConsoleOutputCharacterendl; for (;fSuccess & coord.X lstrlen(lpszString)+x; coord.X += nColors) fSuccess = WriteConsoleO

10、utputAttribute( hOutput, / screen buffer handle wColors, / pointer to source string nColors, / length of string coord, / first cell to write to &cWritten); / actual number written if (! fSuccess) couterror:WriteConsoleOutputAttributeendl;return 0;附件3主文件 main.cpp#include #include #include #include co

11、lorConsole.h/投筛子void rolldice(HANDLE hOutput,int n,int col,int row,WORD wColors);void main(void) HANDLE handle;WORD wColors1;int row,col;/初始化handle = initiate();/生成6个不同骰子wColors0=FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_INTENSITY;row=col=2;for (int i=0;i6;i+)rolldice(handle,i+1,col,row+6*i,wColors

12、);/打印屏幕底部菜单 WORD wMenuColors1;wMenuColors0=FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY;textout(handle,1,24,wMenuColors,1, 游戏规则:);textout(handle,11,24,wMenuColors,1,投掷开始/结束=ENTER;);textout(handle,34,24,wMenuColors,1,更换游戏者=空格;);textout(handle,53,24,wMenuColors,1,退出=q.);bool flag=false;int coun

13、t=1;int sum=0;/随机数的种子srand( (unsigned)time( NULL );col=15;row=8;/游戏开始while(1) if (_kbhit()int ch=_getch();if (ch=13) flag=!flag; if (!flag)wColors0=FOREGROUND_RED|FOREGROUND_INTENSITY; rolldice(handle,i+1,row,col,wColors);/记录游戏者和点数char buf20;itoa(count,buf,10); textout(handle,1,13+2*count,wMenuColor

14、s,1,buf);textout(handle,3,13+2*count,wMenuColors,1,点数:);sum+=i+1;itoa(sum,buf,10);textout(handle,9,13+2*count,wMenuColors,1,buf);else if (ch=32)/更换游戏者sum=0;count+;else if (ch=q | ch=Q) break; if (flag)/随机投筛子i=rand() % 6;wColors0=FOREGROUND_RED|FOREGROUND_INTENSITY; rolldice(handle,i+1,row,col,wColor

15、s);Sleep(100);wColors0=0;rolldice(handle,i+1,row,col,wColors); void rolldice(HANDLE hOutput,int n,int col ,int row,WORD wColors)switch(n)case 1: textout(hOutput,row+1,col+1,wColors,1,); break;case 2:textout(hOutput,row+1,col, wColors,1,); textout(hOutput,row+1,col+2,wColors,1,); break;case 3:textout

16、(hOutput,row, col+2,wColors,1,); textout(hOutput,row+1,col+1,wColors,1,);textout(hOutput,row+2,col, wColors,1,); break;case 4:textout(hOutput,row, col, wColors,1,); textout(hOutput,row, col+2,wColors,1,);textout(hOutput,row+2,col, wColors,1,);textout(hOutput,row+2,col+2,wColors,1,); break;case 5:tex

17、tout(hOutput,row, col, wColors,1,); textout(hOutput,row, col+2,wColors,1,); textout(hOutput,row+1,col+1,wColors,1,);textout(hOutput,row+2,col, wColors,1,);textout(hOutput,row+2,col+2,wColors,1,); break;case 6:textout(hOutput,row, col, wColors,1,); textout(hOutput,row, col+1,wColors,1,); textout(hOut

18、put,row, col+2,wColors,1,); textout(hOutput,row+2,col, wColors,1,);textout(hOutput,row+2,col+1,wColors,1,);textout(hOutput,row+2,col+2,wColors,1,); break; default:cout投掷骰子失败!endl;#include #include #include #include #include colorConsole.hHANDLE initiate();void main(void) HANDLE handle;handle = initi

19、ate(); WORD wColors2;wColors0=FOREGROUND_RED| FOREGROUND_INTENSITY; wColors1=FOREGROUND_RED|FOREGROUND_GREEN| FOREGROUND_INTENSITY; int y=20,x=7; while(x80) int i=_getch(); if (i=w) textout(handle,x,y,wColors,1, ); Sleep(100);textout(handle,x,y,wColors,1, );y-;textout(handle,x,y,wColors,1,); if (i=s

20、) textout(handle,x,y,wColors,1,);Sleep(100);textout(handle,x,y,wColors,1, );y+;textout(handle,x,y,wColors,1,); if (i=d) textout(handle,x,y,wColors,1, ); x+ ; if (i=a) textout(handle,x,y,wColors,1, ); x-; #include #include #include #include #include colorConsole.hHANDLE initiate();void main(void) HAN

21、DLE handle;handle = initiate(); WORD wColors1;wColors0=FOREGROUND_RED| FOREGROUND_INTENSITY; /wColors1=FOREGROUND_RED|FOREGROUND_GREEN| FOREGROUND_INTENSITY; WORD wbackColors1; wbackColors0=FOREGROUND_RED|FOREGROUND_GREEN| FOREGROUND_INTENSITY; for(int j=5;j15;j+) textout(handle,5,j,wbackColors,1,);

22、for(int i=5;i15;i+) textout(handle,25,i,wbackColors,1,); int y=6,x=7; while(x25) int i=_getch(); if (i=w) textout(handle,x,y,wColors,1,); Sleep(100);textout(handle,x,y,wColors,1, );y-;textout(handle,x,y,wColors,1,); if (i=s) textout(handle,x,y,wColors,1,);Sleep(100);textout(handle,x,y,wColors,1, );y

23、+;textout(handle,x,y,wColors,1,); if (i=d) textout(handle,x,y,wColors,1,); x+ ; if (i=a) textout(handle,x,y,wColors,1,); x-; #include #include #include #include #include colorConsole.hHANDLE initiate();void main(void) HANDLE handle;handle = initiate(); WORD wColors1;wColors0=FOREGROUND_RED| FOREGROU

24、ND_INTENSITY; /wColors1=FOREGROUND_RED|FOREGROUND_GREEN| FOREGROUND_INTENSITY; WORD wbackColors1; wbackColors0=FOREGROUND_RED|FOREGROUND_GREEN| FOREGROUND_INTENSITY; for(int j=5;j15;j+) textout(handle,5,j,wbackColors,1,);for(int i=5;i15;i+) textout(handle,25,i,wbackColors,1,); int y=6,x=7; int m=10,

25、n=10; textout(handle,m,n,wColors,1,); while(x25&m25) int i=_getch(); / if(x=m&y=n) if (i=w) if(y=n+2&x=m) textout(handle,x,y,wColors,1,); textout(handle,m,n,wColors,1,); Sleep(100);textout(handle,x,y,wColors,1, ); textout(handle,m,n,wColors,1, );y-;n-; textout(handle,x,y,wColors,1,);textout(handle,m

26、,n,wColors,1,); else textout(handle,x,y,wColors,1,); Sleep(100);textout(handle,x,y,wColors,1, );y-;textout(handle,x,y,wColors,1,); if (i=s) if(y=n-2&x=m) textout(handle,x,y,wColors,1,); textout(handle,m,n,wColors,1,); Sleep(100);textout(handle,x,y,wColors,1, ); textout(handle,m,n,wColors,1, );y+;n+;

27、textout(handle,x,y,wColors,1,);textout(handle,m,n,wColors,1,); else textout(handle,x,y,wColors,1,);Sleep(100);textout(handle,x,y,wColors,1, );y+;textout(handle,x,y,wColors,1,); if (i=d) if(x=m-2) textout(handle,x,y,wColors,1,); textout(handle,m,n,wColors,1,); x+ ; m+; elsetextout(handle,x,y,wColors,

28、1,);x+; if (i=a) if(x=m+2) textout(handle,x,y,wColors,1,); textout(handle,m,n,wColors,1,); x- ; m-; else textout(handle,x,y,wColors,1,); x-; #include #include #include #include #include colorConsole.hHANDLE initiate();void main(void) HANDLE handle;handle = initiate(); WORD wColors1;wColors0=FOREGROU

29、ND_RED| FOREGROUND_INTENSITY; /wColors1=FOREGROUND_RED|FOREGROUND_GREEN| FOREGROUND_INTENSITY; WORD wbackColors1; wbackColors0=FOREGROUND_RED|FOREGROUND_GREEN| FOREGROUND_INTENSITY; for(int j=5;j15;j+) textout(handle,5,j,wbackColors,1,);for(int i=5;i15;i+) textout(handle,25,i,wbackColors,1,); int y=

30、6,x=7; int m=10,n=10; textout(handle,m,n,wColors,1,); while(x25&m25) int i=_getch(); / if(x=m&y=n) if (i=w) if(y=n+2&x=m) textout(handle,x,y,wColors,1,); textout(handle,m,n,wColors,1,); Sleep(100);textout(handle,x,y,wColors,1, ); textout(handle,m,n,wColors,1, );y-;n-; textout(handle,x,y,wColors,1,);

31、textout(handle,m,n,wColors,1,); else textout(handle,x,y,wColors,1,); Sleep(100);textout(handle,x,y,wColors,1, );y-;textout(handle,x,y,wColors,1,); if (i=s) if(y=n-2&x=m) textout(handle,x,y,wColors,1,); textout(handle,m,n,wColors,1,); Sleep(100);textout(handle,x,y,wColors,1, ); textout(handle,m,n,wCo

32、lors,1, );y+;n+;textout(handle,x,y,wColors,1,);textout(handle,m,n,wColors,1,); else textout(handle,x,y,wColors,1,);Sleep(100);textout(handle,x,y,wColors,1, );y+;textout(handle,x,y,wColors,1,); if (i=d) if(x=m-2) textout(handle,x,y,wColors,1,); textout(handle,m,n,wColors,1,); x+ ; m+; elsetextout(han

33、dle,x,y,wColors,1,);x+; if (i=a) if(x=m+2) textout(handle,x,y,wColors,1,); textout(handle,m,n,wColors,1,); x- ; m-; else textout(handle,x,y,wColors,1,); x-; #include #include #include #include #include colorConsole.h #define KEY_UP 72#define KEY_DOWN 80#define KEY_LEFT 75#define KEY_RIGHT 77#define

34、KEY_ESC 27#define MAPW 12 /地图的宽度#define MAPH 20 /地图的高度void Init();/初始化工作void Turn(int a4,int w,int h,int *x,int y); /方块转动bool IsAvailable(int a,int x,int y,int w,int h); /判定是否能放下void DrawBlocks(int a,int w,int h,int x,int y,WORD wColors,int nColors);void ClearSquare(int *a,int w,int h,int x,int y);v

35、oid GameOver();void DeleteLine(int mMAPW,int row,int w,int h); /消除一行HANDLE handle;/7种不同形状的方块int b744=1,1,1,1,0,2,2,2,2,3,3,0,3,3,0,0,4,4,4,4,0,5,5,5,5, 6,6,6,6, 7,7,7,7 ;WORD SQUARE_COLOR7 = FOREGROUND_RED|FOREGROUND_INTENSITY, FOREGROUND_GREEN|FOREGROUND_INTENSITY,FOREGROUND_BLUE|FOREGROUND_INTENSI

36、TY,FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY,FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY,FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY,FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY ;int mapMAPHMAPW = 0; /保存工作区的区域int dx = 24 ; /初始化屏幕时起始坐标int dy = 3;in

37、t main()int score=0; /初始化分数int level=0; /初始化游戏级别int Num = rand() %7 ; /创建第一个方块编号int nextNum = Num; /保存下一个方块编号int blank; /记录每个方块起始位置int x = 0,y = 0; /记录游戏开始的相对坐标int a44 = 0; /临时使用用来保存当前方块Init();while(1)for(int i=0;i4;i+) /复制方块for(int j=0;j4;j+)if(aij = bnextNumij) blank=i;y = 1- blank;x = 4;/创建下一个方块N

38、um = nextNum;ClearSquare(bNum0,4,4,13,13);nextNum = rand() % 7 ;WORD wColors1= SQUARE_COLORnextNum ;DrawBlocks(bnextNum0,4,4,13,13,wColors,1);wColors0 = SQUARE_COLORNum ;DrawBlocks(&a00,4,4,x,y,wColors,1);/显示分数信息char string5;wColors0=FOREGROUND_RED| FOREGROUND_GREEN|FOREGROUND_INTENSITY;textout(hand

39、le,26+dx,5+dy,wColors,1,itoa(score,string,10);textout(handle,26+dx,9+dy,wColors,1,itoa(level,string,10);int max_delay = 100-10*level; /计算不同游戏级别的下落时间间隔while(1)int delay=0; /延迟量while(delaymax_delay)if(_kbhit() /用if避免按住键使方块卡住int key=_getch();switch (key)case KEY_UP:ClearSquare(&a00,4,4,x,y);Turn(a,4,4,

40、&x,y);wColors0=SQUARE_COLORNum;DrawBlocks(&a00,4,4,x,y,wColors,1);break;case KEY_DOWN:delay=max_delay;break;case KEY_LEFT:if(IsAvailable(&a00,x-1,y,4,4)ClearSquare(&a00,4,4,x,y);x-;wColors0=SQUARE_COLORNum;DrawBlocks(&a00,4,4,x,y,wColors,1);break;case KEY_RIGHT:if(IsAvailable(&a00,x+1,y,4,4)ClearSqu

41、are(&a00,4,4,x,y);x+;wColors0=SQUARE_COLORNum;DrawBlocks(&a00,4,4,x,y,wColors,1);break;case KEY_ESC:exit(EXIT_SUCCESS);break;_sleep(8);delay+;if(IsAvailable(&a00,x,y+1,4,4) /是否能下移ClearSquare(&a00,4,4,x,y);y+;wColors0=SQUARE_COLORNum;DrawBlocks(&a00,4,4,x,y,wColors,1);elseif(y=1) GameOver(); /是否结束for

42、(int i=0;i4;i+) /放下方块,更新工作区for(int j=0;j4;j+)if(aij&(i+y)MAPH-1)&(j+x)MAPW-1) mapi+yj+x=aij;int full,k=0;for(int a=y;imin(a+4,MAPH-1);a+)full=1;for(int j=1;j11;j+)if(!mapij) full=0;if(full) /消掉一行DeleteLine(map,i,MAPW,MAPH);k+;score=score+k;level=min(score/30,9);max_delay=100-10*level;break; return E

43、XIT_SUCCESS;void Init()handle=initiate();srand(2);/time(NULL);/初始化工作区for(int i=0;i20;i+)mapi0=-2;mapi11=-2;for(int j=0;j12;j+)map0j=-1;map19j=-1;map00=-3;map011=-3;map190=-3;map1911=-3;WORD wColors1=FOREGROUND_RED| FOREGROUND_GREEN|FOREGROUND_INTENSITY;textout(handle,26+dx,3+dy,wColors,1,SCORE);text

44、out(handle,26+dx,7+dy,wColors,1,LEVEL);textout(handle,26+dx,11+dy,wColors,1,NEXT);wColors0=FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY;DrawBlocks(&map00,12,20,0,0,wColors,1);textout(handle,dx,dy,wColors,1,);wColors0=FOREGROUND_RED| FOREGROUND_GREEN|FOREGROUND_INTENSITY;textout(handle,dx-16,dy,wColors,1,按任意键开始);int ch=_getch();textout(handle,dx-16,dy,wColors,1, );bool IsAvailable(int a,int x,int y,int w,int h)for(int i=max(y,1);iy+h;i+)for(int j=x;jx+w

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论