//Beep()函数,头文件windows.h
//函数内容(赫兹,持续时间)
#include
#include
typedef struct
{
int freq; //赫兹
int duration;//持续时间
char text[32];//文本内容
}STU;
STU t[]=
{{784, 375, "祝"}, {784, 125, "你"}, {880, 500, "生"}, {784, 500, "日"}, {1046, 500, "快"}, {988, 1000, "乐\n"},
{784, 375, "祝"}, {784, 125, "你"}, {880, 500, "生"}, {784, 500, "日"}, {1175, 500, "快"},
{1046, 1000, "乐\n"}, {784, 375, "祝"}, {784, 125, "你"}, {1568, 500, "生"}, {1318, 500, "日"},
{1046, 500, "快"}, {988, 500, "乐\n"}, {880, 500, ""}, {1397, 375, "祝"}, {1397, 125, "你"},
{1318, 500, "生"}, {1046, 500, "日"}, {1175, 500, "快"}, {1046, 1000, "乐\n"}, };
main()
{
int i;
//结构体数组的长度sizeof(t)/sizeof(STU)得到,总结构体数组大小 / 单个结构体大小
for (i=0; i
《童年》(替换t数组即可)
t[] = {{1318, 250, ""}, {1318, 500, ""}, {1318, 500, ""}, {1318, 250, ""}, {1175, 250, ""}, {1175, 500, ""},
{1046, 250, ""}, {1046, 500, ""}, {1046, 250, ""}, {1175, 250, ""}, {1046, 250, ""},
{880, 250, ""}, {784, 250, ""}, {784, 250, ""}, {784, 500, ""}, {784, 250, ""},
{880, 250, ""}, {784, 250, ""}, {1175, 250, ""}, {1318, 250, ""}, {1046, 500, ""},
{1046, 500, "\n"}, {659, 250, "池"}, {784, 250, "塘"}, {784, 500, "边"}, {784, 250, ""},
{659, 250, "的"}, {880, 250, "榕"}, {880, 250, "树"}, {988, 250, "上"}, {880, 250, ""},
{0, 250, ""}, {880, 250, "只"}, {880, 250, "了"}, {784, 250, "在"}, {1046, 500, "声"},
{1046, 250, "声"}, {1046, 250, "的"}, {1046, 250, "叫"}, {880, 250, ""}, {1046, 250, "着"},
{880, 250, "夏"}, {784, 500, "天"}, {784, 500, ","}, {659, 250, "操"}, {784, 250, "场"},
{784, 500, "边"}, {784, 250, ""}, {659, 250, "的"}, {880, 250, "秋"}, {880, 250, "千"},
{988, 250, "上"}, {880, 250, ","}, {0, 250, ""}, {880, 250, "只"}, {880, 250, "有"},
{784, 250, ""}, {1046, 500, "蝴"}, {1046, 375, "蝶"}, {1046, 125, ""}, {1046, 250, "停"},
{880, 250, "在"}, {880, 250, "上"}, {1046, 250, ""}, {1175, 500, "面"}, {1175, 500, "。"},
{1568, 250, "黑"}, {1568, 500, "板"}, {1568, 125, "上"}, {1568, 125, ""}, {1568, 250, ""},
{1568, 250, "老"}, {1318, 250, "师"}, {1175, 250, "的"}, {1046, 250, "粉"}, {1046, 500, "笔"},
{880, 250, "还"}, {880, 250, ""}, {880, 250, ""}, {1046, 250, "在"}, {880, 250, "拼"},
{1046, 250, "命"}, {1175, 250, "叽"}, {1175, 250, "叽"}, {1175, 250, "喳"}, {1046, 250, "喳"},
{1175, 250, "写"}, {1046, 250, "个"}, {1318, 250, "不"}, {1175, 250, ""}, {1175, 500, "停"},
{1175, 500, ","}, {1318, 250, "等"}, {1318, 500, "待"}, {1318, 250, "着"}, {1318, 250, "下"},
{1175, 250, ""}, {1175, 500, "课"}, {1046, 250, "等"}, {1046, 500, "待"}, {1046, 250, "着"},
{1175, 250, "放"}, {1046, 250, ""}, {880, 250, "学"}, {784, 250, ","}, {784, 250, "等"},
{784, 250, "待"}, {0, 250, ""}, {784, 250, "有"}, {880, 250, "趣"}, {784, 250, "的"},
{1175, 250, "童"}, {1318, 250, ""}, {1046, 500, "年"}, {1046, 500, "。"}, {1046, 500, "\n"},
{659, 250, "总"}, {784, 250, "是"}, {784, 500, "要"}, {784, 250, "等"}, {659, 250, "到"},
{880, 250, "睡"}, {880, 250, "觉"}, {988, 250, "前"}, {880, 250, ""}, {0, 250, ""},
{880, 250, "才"}, {880, 250, "知"}, {784, 250, "道"}, {1046, 500, "功"}, {1046, 250, "课"},
{1046, 250, "只"}, {1046, 250, "做"}, {880, 250, "了"}, {1046, 250, "一"}, {880, 250, "点"},
{784, 500, "点"}, {784, 500, ","}, {659, 250, "总"}, {784, 250, "是"}, {784, 500, "要"},
{784, 250, "等"}, {659, 250, "到"}, {880, 250, "考"}, {880, 250, "试"}, {988, 250, "以"},
{880, 250, "后"}, {0, 250, ""}, {880, 250, "才"}, {880, 250, "知"}, {784, 250, "道"},
{1046, 500, "该"}, {1046, 375, "念"}, {1046, 125, "的"}, {1046, 250, "书"}, {880, 250, "都"},
{880, 250, "没"}, {1046, 250, "有"}, {1175, 500, "念"}, {1175, 500, "。"}, {1568, 250, "一"},
{1568, 500, "寸"}, {1568, 125, "光"}, {1568, 125, ""}, {1568, 250, ""}, {1568, 250, "阴"},
{1318, 250, "一"}, {1175, 250, "寸"}, {1046, 250, "金"}, {1046, 500, ""}, {880, 250, "老"},
{880, 250, "师"}, {880, 250, "说"}, {1046, 250, "过"}, {880, 250, "寸"}, {1046, 250, "金"},
{1175, 250, "难"}, {1175, 250, ""}, {1175, 250, "买"}, {1046, 250, ""}, {1175, 250, "寸"},
{1046, 250, ""}, {1318, 250, "光"}, {1175, 250, ""}, {1175, 500, "阴"}, {1175, 500, ","},
{1318, 250, "一"}, {1318, 500, "天"}, {1318, 250, "又"}, {1318, 250, "一"}, {1175, 250, ""},
{1175, 500, "天"}, {1046, 250, "一"}, {1046, 500, "年"}, {1046, 250, "又"}, {1175, 250, "一"},
{1046, 250, ""}, {880, 250, "年"}, {784, 250, ","}, {784, 250, "迷"}, {784, 250, "迷"},
{0, 250, ""}, {784, 250, "糊"}, {880, 250, "糊"}, {784, 250, "的"}, {1175, 250, "童"},
{1318, 250, ""}, {1046, 500, "年"}, {1046, 500, "。"}, {1046, 500, "\n"}, {1318, 500, "噢"},
{1318, 250, "一"}, {1318, 500, "天"}, {1318, 250, "又"}, {1318, 250, "一"}, {1175, 250, ""},
{1175, 500, "天"}, {1046, 250, "一"}, {1046, 500, "年"}, {1046, 250, "又"}, {1175, 250, "一"},
{1046, 250, ""}, {880, 250, "年"}, {784, 250, ","}, {784, 250, "盼"}, {784, 250, "望"},
{0, 250, ""}, {784, 250, "长"}, {880, 250, "大"}, {784, 250, "的"}, {1175, 250, "童"},
{1318, 250, ""}, {1046, 500, "年"}, {1046, 500, "。"}, {0, 500, ""}, };