资源描述:
《哈工大C语言课程设计汇本汇本》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、HarbinInstituteofTechnology课程设计说明书(论文)课程名称:C语言课程设计设计题目:音乐程序与波特图院系:航天学院控制科学与工程系班级:设计者:学号:指导教师:设计时间:哈尔滨工业大学教务处哈尔滨工业大学课程设计任务书姓名:院(系):专业:班号:任务起至日期:年月日至年月日课程设计题目:已知技术参数和设计要求:工作量:工作计划安排:同组设计者及分工:指导教师签字___________________年月日教研室主任意见:教研室主任签字___________________年月日*注:此任务书由课程设计指导教师填写。题目一1.1题目详细描述:播放音乐程序,实现了
2、自选音乐曲目和直接使用键盘弹奏,而且可以在曲目播放结束后循环选择乐曲。开始1.2程序设计思路及流程图:绘制文本背景并功能说明打印用户选择曲目,或者选择自己利用键盘弹奏。选择歌曲弹奏放歌是否继续是结束1.3程序清单及注释:#include#include#include#include#include#include#defineN116#defineN28#defineN44#defineN82#defineN161#defineEND0voidplaymusic(intn,int*c
3、);voidtypemusic();enumNOTES{C10=131,D10=147,E10=165,F10=175,G10=196,A10=220,B10=247,C0=262,D0=296,E0=330,F0=349,G0=392,A0=440,B0=494,C1=523,D1=587,E1=659,F1=698,G1=784,A1=880,B1=988,C2=1047,D2=1175,E2=1319,F2=1397,G2=1568,A2=1760,B2=1976,S=10};typedefenumNOTESSONG;SONGsong1[]={C0,N4+N2,E0,N4,G0,
4、N2,G0,N2,A0,N1,G0,N1,E0,N4+N2,C0,N4,G0,N1/3,G0,N1/3,G0,N1/3,E0,N1,C0,N1,G10,N1/3,G10,N1/3,G10,N1/3,G10,N1/3,G10,N1/3,G10,N1/3,C0,N1,END,END};SONGsong2[]={A0,N2,B0,N2,C1,N1+N2,B0,N2,C1,N1,E1,N1,B0,N1+N1,S,N1,E0,N1,A0,N1+N2,G0,N2,A0,N1,C1,N1,G0,N1+N1,S,N1,E0,N2,E0,N2,F0,N1+N2,E0,N2,F0,N1,C0,N1,E0,
5、N1+N1,S,N1,C1,N2,C1,N2,B0,N1+N2,370,N2,F0,N1,B0,N1,B0,N1+N2,S,N1,A0,N2,B0,N2,C1,N1+N2,B0,N2,C1,N1,E1,N1,B0,N1+N2,END,END};intmain(){intm,n,c=1;charb='y';while(b=='y'){printf("Hello,whatdoyouwanttodobythisprogram?");printf("1.Listentomusic.-------Press1");printf("2.Playmusicbyyourself.-------
6、Press2");scanf("%d",&m);while(m!=1&&m!=2&&m!=3)/*选择方式*/{printf("Youtypedwrong!Donotpushmearound.:(");scanf("%d",&m);}if(m==1){printf("Ihavetwomusics,chooseone!(Press1/2)");scanf("%d",&n);while(n!=1&&n!=2){printf("Youtypedwrong!Donotpushmearound.:(");scanf("%d",&n);}playmusic(n,&c);}elsei
7、f(m==2){typemusic();}getchar();printf("Doyouwanttocontinue?(y/n)");scanf("%c",&b);}return0;}voidplaymusic(intn,int*c){intnote=0,fre,dur,control;chard;clock_tgoal;if(n==1){while(song1[note]!=END){fre=*c*song1[note];dur=song