想给朋友送一个祝他生日快乐的C语言程序,跪求大神赐我一个,谢谢了~

2024-11-25 20:19:31
推荐回答(1个)
回答1:

#include
#include
unsigned int rhythm[] = {
0x188, 0x188, 0x1B8, 0x188, 0x20B, 0x1EE,
0x188, 0x188, 0x1B8, 0x188, 0x24B, 0x20B,
0x188, 0x188, 0x310, 0x293, 0x20B, 0x1EE,
0x1B8, 0x2BA, 0x2BA, 0x293, 0x20B, 0x24B,
0x20B
};
unsigned int delay[] = {
0x177, 0x07D, 0x1F4, 0x1F4, 0x1F4, 0x3E8,
0x177, 0x07D, 0x1F4, 0x1F4, 0x1F4, 0x3E8,
0x177, 0x07D, 0x1F4, 0x1F4, 0x1F4, 0x1F4, 0x3E8,
0x177, 0x07D, 0x1F4, 0x1F4, 0x1F4, 0x3E8,
};
void play_music();//奏乐
int main(int argc, char *argv[])
{
puts("happy birthday ! \n");
play_music();
return 0;
}
void play_music()
{
int i = 0;
for(; i < 25; ++i)
{
Beep(rhythm[i]*5, delay[i]);
if(i == 24)
{
Sleep(500);
i = 0;
}
}
}