C语言程序设计实训 release目录

源代码在线查看: 9-7.c

软件大小: 40 K
上传用户: bonylee_java
关键词: release C语言 程序设计 目录
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*9-7.c*/
				#define SPEED 10
				#include
				#include
				
				void pause(int time)
				{
				int t1,t2;
				union REGS in;
				union REGS out;
				in.h.ah=0x2c;
				int86(0x21, &in, &out);
				t1=t2=100*out.h.dh+out.h.dl;
				while(t2-t1				{ int86(0x21,&in, &out);
				t2=100*out.h.dh+out.h.dl;
				if (t2				}
				}
				void sound1(int freq, int time)
				{
				  union {
				long divisor;
				unsigned char c[4];
				} count;
				unsigned char ch;
				count.divisor=1193280/freq;
				outp(67,182);
				outp(66, count.c[0]);
				outp(66, count.c[1]);
				ch=inp (97);
				outp(97,ch|3);
				pause (time);
				outp (97,ch);
				}
				
				main()
				{
				int freq,i;
				int time=4*SPEED;
				char *qiu="iddgwwwqqgff ddddfghhhggg ddgwwwqqgff \
				ddgghjqqqqqqiwp igigjhgddgqqq hhqwwqjjjggg \
				ddgwwwqqgfff ddgghjqqqqqq";
				while(*qiu++!='\0') {
				i=1;
				switch(*qiu) {
				 case 'k': time=1*SPEED;
					 i=0;
					 break;
				   case 'l': time=2*SPEED;
					 i=0;
					 break;
				case 'i': time=4*SPEED;
				 i=0;
				break;
				case 'o': time=6*SPEED;
				i=0;
				break ;
				   case 'a': freq=523;
					 break;
				case 's' : freq=587;
					 break;
				   case 'd': freq=659;
				   break;
				case 'f' : freq=698;
					  break ;
				   case 'g': freq=784;
					  break;
				case 'h' : freq=880;
					  break ;
					case 'j': freq=998;
					  break;
				case 'z' : freq=262;
					  break;
					case 'x': freq=294;
					  break;
				case 'c' : freq=330;
					  break;
					case 'v': freq=349;
					  break;
				case 'b' : freq=392;
					  break;
				case 'n': freq=440;
					  break;
				case 'm' : freq=949;
					  break;
				case 'q': freq=1047;
					  break;
				case 'w' : freq=1175;
					  break;
				case 'e': freq=1319;
					  break;
				case 'r' : freq=1397;
					  break;
				case 't': freq=1568;
					  break;
				case 'y' : freq=1760;
					  break;
				case 'u': freq=1976;
					  break;
				default: i=0;
					  break;
				}
				if(i) sound1(freq, time);
				}
				}
							

相关资源