91.c

来自「上百个标准C语言的源代码」· C语言 代码 · 共 72 行

C
72
字号
  #define FALSE 0
 #define TRUE 1
 #include<dos.h>
main()
{
int snd;    /*  which sound to produce  */
int cnt;    /* number of times to repeat sound */
int note;   /* Current note, when sweeping frequencies  */
while (TRUE) {
/* Male Sure any previous sounds ave turned off.  */
   nosound();
/* Ask the user for which type of sounf*/
printf ("1-siren;2-overload;3-whoop;4-phaser; 0-exit");
/* read the answer */
   scanf ("%d",&snd);
/* if the  answer it to exit ,do so. */
   if (snd==0)
   break;
/* Ask how many times to repast the sound. */
printf ("Nunger of times:");
/* get the answer */
scanf("%d",&cnt);
/* repeat the sound the number of time specifed */
while(cnt--){
/* swich on type of sound to produce*/
switch (snd)
{case 1:
  /* do a siren:sweep up */
for (note=1000;note>150;note-=10)
{
sound(note);
delay(20);
}
/* Sweep down */
for (;note<1000;note+=10)
{
sound(note);
  delay(20);
}
break;
case 2:  /* do an overload. sweep up */
		for (note=4000;note>10;note-=10)
{
sound(note);
delay(70);
}
break;
case 3:
	   /* do a whoop: Sweep up*/
	   for (note=1000;note>10;note-=10)
		 {
		 sound (note);
delay (200);
}
break;
case 4:
	  /* do a phaser: sweep down */
	  for (note=60; note<2000;note+=10 )
{
sound (note);
delay(100);
}
break;
default:
		   /* unknown,ask a gain */
		   printf ( "Invalid entry;try again \n");
		   break;
}
}
}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?