生日快乐音乐小程序

#include "iostream"
#include "time.h"
#include 
#include 
#include 
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();

}


你可能感兴趣的:(c语言基础知识)