请教大家一个VC++程序的改进

来源:百度知道 编辑:UC知道 时间:2024/05/25 13:38:14
#include <dos.h>
#include <stdlib.h>
main(){
char *Info="\
\\Welcome to play this game!\
\n\
\n\
\n\
In this game,you will drive a warship to fight with\n\
the submarines.\n\n\
KEYS:\n\
'Left' and 'Right' keys to move your warship.\n\
'Space bar' or 'Ctrl' key to send bombs.\n\
'S' key is a sound switch.\n\
'D' key is a state switch.\n\n\
\n\
\n\n\
GOOD LUCK!\0";

while (*Info++)
{
sound(5000);
delay(20000);
printf("%c",*(Info-1));
nosound();
}
getch();
}
*******************************************

函数void sound(unsigned frequency)以指定频率打开PC扬声器

sound(频率)

频率单位 赫兹(HZ)
音名 频率
C 1 do 256
D 2 re 288
E 3 mi 320
F 4 fa 341又1/3
G 5 so 384
A 6 la 426又2/3
B 7 si 480
C 1 (上面一个点)do 512

C:D=8:9
D:E=9:10
E:F=15:16
F:G=8;9
G:A=9:10
A:B=15:16
三三循环,以此类推