哈,用的蜂鸣器,我静音了这东西还放。
只能调的很垃圾,但是很好玩。
1 #include<cstdio> 2 #include<windows.h> 3 using namespace std; 4 #define a 60 5 #define b 42 6 #define d Beep(523,a*4);Sleep(b*4); 7 #define d2 Beep(523,a*2);Sleep(b*2); 8 #define d4 Beep(523,a);Sleep(b); 9 #define d_ Beep(523,a*8);Sleep(b*8); 10 #define d__ Beep(523,a*12);Sleep(b*12); 11 #define d___ Beep(523,a*16);Sleep(b*16); 12 13 #define r Beep(578,a*4);Sleep(b*4); 14 #define r3 Beep(578,a*6);Sleep(b*6); 15 #define r2 Beep(578,a*2);Sleep(b*2); 16 #define r4 Beep(578,a);Sleep(b); 17 #define r_ Beep(578,a*8);Sleep(b*8); 18 #define r___ Beep(578,a*16);Sleep(b*16); 19 20 #define m Beep(659,a*4);Sleep(b*4); 21 #define m2 Beep(659,a*2);Sleep(b*2); 22 #define m4 Beep(659,a);Sleep(b); 23 #define m_ Beep(659,a*8);Sleep(b*8); 24 #define m___ Beep(659,a*16);Sleep(b*16); 25 26 #define f Beep(698,a*4);Sleep(b*4); 27 #define f2 Beep(698,a*2);Sleep(b*2); 28 #define f4 Beep(698,a);Sleep(b); 29 #define f_ Beep(698,a*8);Sleep(b*8); 30 #define f___ Beep(698,a*16);Sleep(b*16); 31 32 #define s Beep(784,a*4);Sleep(b*4); 33 #define s3 Beep(784,a*6);Sleep(b*6); 34 #define s2 Beep(784,a*2);Sleep(b*2); 35 #define s4 Beep(784,a);Sleep(b); 36 #define s_ Beep(784,a*8);Sleep(b*8); 37 #define s___ Beep(784,a*16);Sleep(b*16); 38 39 #define l Beep(880,a*4);Sleep(b*4); 40 #define l2 Beep(880,a*2);Sleep(b*2); 41 #define l4 Beep(880,a);Sleep(b); 42 #define l_ Beep(880,a*8);Sleep(b*8); 43 #define l___ Beep(880,a*16);Sleep(b*16); 44 45 #define x Beep(988,a*4);Sleep(b*4); 46 #define x2 Beep(988,a*2);Sleep(b*2); 47 #define x4 Beep(988,a);Sleep(b); 48 #define x_ Beep(988,a*8);Sleep(b*8); 49 #define x___ Beep(988,a*16);Sleep(b*16); 50 51 #define o Sleep(b*4+a*4); 52 #define o2 Sleep(b*2+a*2); 53 #define o4 Sleep(b+a); 54 #define o_ Sleep(b*8+a*8); 55 #define o___ Sleep(b*16+a*16); 56 57 #define dd Beep(262,a*4);Sleep(b*4); 58 #define dd2 Beep(262,a*2);Sleep(b*2); 59 #define dd4 Beep(262,a);Sleep(b); 60 #define dd_ Beep(262,a*8);Sleep(b*8); 61 #define dd___ Beep(262,a*16);Sleep(b*16); 62 63 #define rr Beep(294,a*4);Sleep(b*4); 64 #define rr2 Beep(294,a*2);Sleep(b*2); 65 #define rr4 Beep(294,a);Sleep(b); 66 #define rr_ Beep(294,a*8);Sleep(b*8); 67 #define rr___ Beep(294,a*16);Sleep(b*16); 68 69 #define mm Beep(330,a*4);Sleep(b*4); 70 #define mm2 Beep(330,a*2);Sleep(b*2); 71 #define mm4 Beep(330,a);Sleep(b); 72 #define mm_ Beep(330,a*8);Sleep(b*8); 73 #define mm___ Beep(330,a*16);Sleep(b*16); 74 75 #define ff Beep(349,a*4);Sleep(b*4); 76 #define ff2 Beep(349,a*2);Sleep(b*2); 77 #define ff4 Beep(349,a);Sleep(b); 78 #define ff_ Beep(349,a*8);Sleep(b*8); 79 #define ff___ Beep(349,a*16);Sleep(b*16); 80 81 #define ss Beep(392,a*4);Sleep(b*4); 82 #define ss2 Beep(392,a*2);Sleep(b*2); 83 #define ss4 Beep(392,a);Sleep(b); 84 #define ss_ Beep(392,a*8);Sleep(b*8); 85 #define ss___ Beep(392,a*16);Sleep(b*16); 86 87 #define ll Beep(440,a*4);Sleep(b*4); 88 #define ll2 Beep(440,a*2);Sleep(b*2); 89 #define ll4 Beep(440,a);Sleep(b); 90 #define ll_ Beep(440,a*8);Sleep(b*8); 91 #define ll___ Beep(440,a*16);Sleep(b*16); 92 93 #define xx Beep(494,a*4);Sleep(b*4); 94 #define xx2 Beep(494,a*2);Sleep(b*2); 95 #define xx4 Beep(494,a);Sleep(b); 96 #define xx_ Beep(494,a*8);Sleep(b*8); 97 #define xx___ Beep(494,a*16);Sleep(b*16); 98 int main(){ 99 //d=1 r=2 m=3 f=4 s=5 l=6 x=7 100 //dd:低音 d2:二分音符 d4:四分音符 101 //d_=1- d___=1--- 102 //示例:5--- 103 s___; 104 return 0;}
最后给一曲天空之城
http://blog.csdn.net/v1t1p9hvbd/article/details/71523218