哈,用的蜂鸣器,我静音了这东西还放。只能调的很垃圾,但是很好玩。
1 #include2 #include 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=7100 //dd:低音 d2:二分音符 d4:四分音符101 //d_=1- d___=1--- 102 //示例:5---103 s___; 104 return 0;}
最后给一曲天空之城,摘自的博客。
1 #include2 #include 3 #define qdo 262 4 #define qre 294 5 #define qmi 330 //q前缀为低音,1后缀为高音,s前缀为半音阶 6 #define qfa 349 7 #define qso 392 8 #define qla 440 9 #define qsi 494 10 #define do 523 11 #define re 578 12 #define mi 659 13 #define fa 698 14 #define so 784 15 #define la 880 16 #define si 988 17 #define do1 1046 18 #define re1 1175 19 #define mi1 1318 20 #define fa1 1480 21 #define so1 1568 22 #define la1 1760 23 #define si1 1976 24 #define sqdo 277 25 #define sqre 311 26 #define sqfa 370 27 #define sqso 415 28 #define sqla 466 29 #define sdo 554 30 #define sre 622 31 #define sfa 740 32 #define sso 831 33 #define sla 932 34 #define sdo1 1046 35 #define sre1 1245 36 #define sfa1 1480 37 #define sso1 1661 38 #define sla1 1865 39 40 int main() 41 { 42 int pai=400,ban=200; 43 int ting=128; 44 45 Sleep(1000); 46 47 Beep(la,ban); 48 Beep(si,ban); 49 Sleep(ting); 50 51 Beep(do1,pai+ban); 52 Beep(si,ban); 53 Sleep(ting); 54 Beep(do1,pai); 55 Sleep(ting); 56 Beep(mi1,pai); 57 Sleep(ting); 58 59 Beep(si,3*pai); 60 Sleep(ting); 61 Beep(mi,ban); 62 Beep(mi,ban); 63 64 Beep(la,ban+pai); 65 Beep(so,ban); 66 Sleep(ting); 67 Beep(la,pai); 68 Sleep(ting); 69 Beep(do1,pai); 70 Sleep(ting); 71 72 Beep(so,2*pai); 73 Sleep(ting); 74 Sleep(pai); 75 Beep(mi,ban); 76 Sleep(ting/2); 77 Beep(mi,ban); 78 Sleep(ting/2); 79 80 Beep(fa,pai+ban); 81 Beep(mi,ban); 82 Sleep(ting); 83 Beep(fa,ban); 84 Beep(do1,ban+pai); 85 Sleep(ting); 86 87 Beep(mi,2*pai); 88 Sleep(ting); 89 Sleep(ban); 90 Beep(do1,ban); 91 Sleep(ting/2); 92 Beep(do1,ban); 93 Sleep(ting/2); 94 Beep(do1,ban); 95 Sleep(ting/2); 96 97 Beep(si,ban+pai); 98 Beep(sfa,ban); 99 Sleep(ting);100 Beep(sfa,pai);101 Beep(si,pai);102 Sleep(ting);103 104 Beep(si,2*pai);105 Sleep(ting);106 Sleep(pai);107 Beep(la,ban);108 Beep(si,ban);109 Sleep(ting);110 111 Beep(do1,pai+ban);112 Beep(si,ban);113 Sleep(ting);114 Beep(do1,pai);115 Sleep(ting);116 Beep(mi1,pai);117 Sleep(ting);118 119 Beep(si,2*pai);120 Sleep(ting);121 Sleep(pai);122 Beep(mi,ban);123 Sleep(20);124 Beep(mi,ban);125 Sleep(ting);126 127 Beep(la,pai+ban);128 Beep(so,ban);129 Sleep(ting);130 Beep(la,pai);131 Sleep(ting);132 Beep(do1,pai);133 Sleep(ting);134 135 Beep(so,3*pai);136 Sleep(ting+ban);137 Beep(mi,ban);138 Sleep(ting/2);139 140 Beep(fa,pai);141 Sleep(ting);142 Beep(do1,ban);143 Beep(si,ban);144 Sleep(20);145 Beep(si,pai);146 Sleep(ting);147 Beep(do1,pai);148 Sleep(ting);149 150 Beep(re1,ban);151 Sleep(20);152 Beep(re1,ban);153 Sleep(20);154 Beep(mi1,ban);155 Sleep(ting/2);156 Beep(do1,pai);157 Sleep(ting+pai);158 159 Beep(do1,pai);160 Beep(si,ban);161 Sleep(ting);162 Beep(la,ban);163 Sleep(20);164 Beep(la,ban);165 Sleep(ting);166 Beep(si,pai);167 Sleep(ting);168 Beep(sso,pai);169 Sleep(ting);170 171 Beep(sso,2*pai);172 Sleep(ting+pai);173 Beep(do1,ban);174 Beep(re1,ban);175 Sleep(ting);176 177 Beep(mi1,pai+ban);178 Beep(re1,ban);179 Sleep(ting);180 Beep(mi1,pai);181 Sleep(ting);182 Beep(fa1,pai);183 Sleep(ting);184 185 Beep(re1,2*pai);186 Sleep(pai+ting);187 Beep(so,ban);188 Sleep(20);189 Beep(so,ban);190 Sleep(ting);191 192 Beep(do1,ban);193 Beep(si,ban);194 Sleep(ting);195 Beep(do1,pai);196 Sleep(ting);197 Beep(mi1,pai);198 Sleep(ting);199 200 Beep(mi1,2*pai);201 Sleep(ting+2*pai);202 203 Beep(la,ban);204 Beep(si,ban);205 Sleep(ting);206 Beep(do1,pai);207 Sleep(ting);208 Beep(si,pai);209 Sleep(ting);210 Beep(re1,ban);211 Sleep(20);212 Beep(re1,ban);213 Sleep(ting);214 215 Beep(do1,pai+ban);216 Beep(so,ban);217 Sleep(20);218 Beep(so,pai);219 Sleep(pai+ting);220 221 Beep(fa1,pai);222 Sleep(ting);223 Beep(mi1,pai);224 Sleep(ting);225 Beep(re1,pai);226 Sleep(ting);227 Beep(do1,pai);228 Sleep(ting);229 230 Beep(mi1,4*pai);231 232 Beep(mi1,pai*2);233 Sleep(pai+ting);234 Beep(mi1,pai);235 Sleep(ting);236 237 Beep(la1,2*pai);238 Sleep(ting);239 Beep(so1,pai);240 Sleep(ting);241 Beep(so1,pai);242 Sleep(ting);243 244 Beep(mi1,ban);245 Sleep(ting/2);246 Beep(re1,ban);247 Sleep(ting);248 Beep(do1,pai);249 Sleep(ting+ban);250 Beep(do1,ban);251 Sleep(ting);252 253 Beep(re1,pai);254 Sleep(ting);255 Beep(do1,ban);256 Beep(re1,ban);257 Sleep(20);258 Beep(re1,ban);259 Sleep(ting);260 Beep(so1,pai);261 Sleep(ting);262 263 Beep(mi1,2*pai);264 Sleep(ting+pai);265 Beep(mi,pai);266 Sleep(ting);267 268 Beep(la1,2*pai);269 Sleep(ting);270 Beep(so1,2*pai);271 Sleep(ting);272 273 Beep(mi1,ban);274 Beep(re1,ban);275 Sleep(ting);276 Beep(do1,2*pai);277 Sleep(ting+ban);278 Beep(do1,ban);279 Sleep(ting);280 281 Beep(re1,pai);282 Sleep(ting);283 Beep(do1,ban);284 Beep(re1,ban);285 Sleep(20);286 Beep(re1,ban);287 Sleep(ting);288 Beep(si,pai);289 Sleep(ting);290 291 Beep(la,2*pai);292 Sleep(ting);293 Beep(la,ban);294 Beep(si,ban);295 296 Beep(do1,pai+ban);297 Beep(si,ban);298 Sleep(ting);299 Beep(do1,pai);300 Sleep(ting);301 Beep(mi1,pai);302 Sleep(ting);303 304 Beep(si,3*pai);305 Sleep(ting);306 Beep(mi,ban);307 Beep(mi,ban);308 309 Beep(la,ban+pai);310 Beep(so,ban);311 Sleep(ting);312 Beep(la,pai);313 Sleep(ting);314 Beep(do1,pai);315 Sleep(ting);316 317 Beep(so,2*pai);318 Sleep(ting);319 Sleep(pai);320 Beep(mi,ban);321 Sleep(ting/2);322 Beep(mi,ban);323 Sleep(ting/2);324 325 Beep(fa,pai+ban);326 Beep(mi,ban);327 Sleep(ting);328 Beep(fa,ban);329 Beep(do1,ban+pai);330 Sleep(ting);331 332 Beep(mi,2*pai);333 Sleep(ting);334 Sleep(ban);335 Beep(do1,ban);336 Sleep(ting/2);337 Beep(do1,ban);338 Sleep(ting/2);339 Beep(do1,ban);340 Sleep(ting/2);341 342 Beep(si,ban+pai);343 Beep(sfa,ban);344 Sleep(ting);345 Beep(sfa,pai);346 Beep(si,pai);347 Sleep(ting);348 349 Beep(si,2*pai);350 Sleep(ting);351 Sleep(pai);352 Beep(la,ban);353 Beep(si,ban);354 Sleep(ting);355 356 Beep(do1,pai+ban);357 Beep(si,ban);358 Sleep(ting);359 Beep(do1,pai);360 Sleep(ting);361 Beep(mi1,pai);362 Sleep(ting);363 364 Beep(si,2*pai);365 Sleep(ting);366 Sleep(pai);367 Beep(mi,ban);368 Sleep(20);369 Beep(mi,ban);370 Sleep(ting);371 372 Beep(la,pai+ban);373 Beep(so,ban);374 Sleep(ting);375 Beep(la,pai);376 Sleep(ting);377 Beep(do1,pai);378 Sleep(ting);379 380 Beep(so,3*pai);381 Sleep(ting+ban);382 Beep(mi,ban);383 Sleep(ting/2);384 385 Beep(fa,pai);386 Sleep(ting);387 Beep(do1,ban);388 Beep(si,ban);389 Sleep(20);390 Beep(si,pai);391 Sleep(ting);392 Beep(do1,pai);393 Sleep(ting);394 395 Beep(re1,ban);396 Sleep(20);397 Beep(re1,ban);398 Sleep(20);399 Beep(mi1,ban);400 Sleep(ting/2);401 Beep(do1,pai);402 Sleep(ting+pai);403 404 Beep(la,4*pai);405 406 Sleep(1000);407 408 main();409 410 }