生日快乐音乐小程序

#include "iostream"
#include "time.h"
#include <windows.h>
#include <stdio.h>
#include<conio.h> 
using namespace std;

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 i = 0; 
	for(; i < 25; ++i)
	{
	Beep(rhythm[i]*5, delay[i]);


		if(i == 24)
		{
			Sleep(500);
			i = 0;
		}
	}
}

main()

{

    void play_music();//奏乐

    puts("happy birthday ! \n");
    play_music();

}


©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页