c++生日快乐歌代码
时间: 2023-12-10 14:32:48 浏览: 250
c++生日歌代码
5星 · 资源好评率100%
这里提供一份C++的生日快乐歌代码,代码如下:
```
#include<iostream>
#include<Windows.h>
#include<conio.h>
using namespace std;
int main()
{
Beep(523,500);
Beep(523,500);
Beep(587,1000);
Beep(523,1000);
Beep(698,1000);
Beep(659,2000);
Beep(523,500);
Beep(523,500);
Beep(587,1000);
Beep(523,1000);
Beep(784,1000);
Beep(698,2000);
Beep(523,500);
Beep(523,500);
Beep(1047,1000);
Beep(880,1000);
Beep(698,1000);
Beep(659,1000);
Beep(587,1000);
Beep(784,1000);
Beep(698,1000);
Beep(659,1000);
Beep(587,1000);
Beep(523,1000);
Beep(880,1000);
Beep(784,1000);
Beep(698,1000);
Beep(659,1000);
Beep(587,1000);
Beep(523,1000);
getch();
return 0;
}
```
这段代码使用了Windows.h库中的Beep函数,通过调用不同频率的声音来演奏生日快乐歌曲。如果你想了解更多关于Beep函数的信息,可以参考Microsoft官方文档。
阅读全文