c++ Beep函式

專注的阿熊發表於2020-03-23

c++這個Beep函式也是非常磨人性子,在家期間,比較空閒,自己編著玩,寫了個能響的鋼琴曲雪之夢(不認真聽,確實聽不出來)給大家玩玩,這玩應沒有啥難度,但是沒啥藝術細胞的我,發現我確實不行,嘗試寫的迷人的危險失敗了,這裡也發給大家玩玩。

這是雪之夢的


#include <cstdio>

#include <windows.h>

#define qdo 262

#define qre 294

#define qmi 330     //q字首為低音,1字尾為高音,s字首為半音階

#define qfa 349

#define qso 392

#define qla 440

#define qsi 494

#define do2 523

#define re 578

#define mi 659

#define fa 698

#define so 784

#define la 880

#define si 988

#define dol 1046

#define rel 1175

#define mil 1318

#define fal 1480

#define sol 1568

#define lal 1760

#define si1 1976

#define sqdo 277

#define sqre 311

#define sqfa 370

#define sqso 415

#define sqla 466

#define sdo 554

#define sre 622

#define sfa 740

#define sso 831

#define sla 932

#define sdo1 1046

#define sre1 1245

#define sfa1 1480

#define sso1 1661

#define sla1 1865


int main()

{

int pai=400,ban=200;

int ting=128;


Sleep(ban);

Sleep(ting/2);

Beep(so,ban);

Sleep(ting);

Beep(dol,ban);

Sleep(ting/2);

Beep(rel,ban);

Sleep(ting);

Beep(mil,ban);

Sleep(ting/2);

Beep(so,ban);

Sleep(ting);

Beep(rel,ban);

Sleep(ting/2);

Beep(dol,ban);

Sleep(ting);


Sleep(ban);

Sleep(ting/2);

Beep(so,ban);

Sleep(ting);

Beep(dol,ban);

Sleep(ting/2);

Beep(sol,ban);

Sleep(ting);

Beep(fal,ban);

Sleep(ting/2);

Beep(mil,ban);

Sleep(ting);

Beep(rel,ban);

Sleep(ting/2);

Beep(dol,ban);

Sleep(ting);


Sleep(ban);

Sleep(ting/2);

Beep(so,ban);

Sleep(ting);

Beep(dol,ban);

Sleep(ting/2);

Beep(rel,ban);

Sleep(ting);


Beep(mil,ban);

Sleep(ting/2);

Beep(fal,ban);

Sleep(ting);

Beep(sol,ban);

Sleep(ting/2);

Beep(mil,ban);

Sleep(ting);

Beep(rel,pai);

Sleep(ting);

Beep(dol,pai);

Sleep(ting);


Beep(la,pai);

Sleep(ting);

Beep(mil,pai);

Sleep(ting);

Beep(rel,2*pai);

Sleep(ting);


Beep(mil,ban);

Sleep(ting/2);

Beep(fal,ban);

Sleep(ting);

Beep(sol,ban);

Sleep(ting/2);

Beep(mil,ban);

Sleep(ting);

Beep(rel,pai);

Sleep(ting);

Beep(dol,pai);

Sleep(ting);


Beep(lal,pai);

Sleep(ting);

Beep(lal,pai);

Sleep(ting);

Beep(sol,2*pai);

Sleep(ting);


Beep(mil,ban);

Sleep(ting/2);

Beep(fal,ban);

Sleep(ting);

Beep(sol,ban);

Sleep(ting/2);

Beep(mil,ban);

Sleep(ting);

Beep(rel,pai);

Sleep(ting);

Beep(dol,pai);

Sleep(ting);


Beep(la,pai);

Sleep(ting);

Beep(mil,pai);

Sleep(ting);

Beep(rel,pai);

Sleep(ting);

Beep(si,ban);

Sleep(ting/2);

Beep(la,ban);

Sleep(ting);

美元符號

http://www.gendan5.com/currency/USD.html

Beep(so,pai);

Sleep(ting);

Beep(rel,pai);

Sleep(ting);

Beep(dol,pai);

Sleep(ting);

Beep(rel,ban);

Sleep(ting/2);

Beep(mil,ban);

Sleep(ting);


Beep(fal,ban);

Sleep(ting/2);

Beep(mil,ban);

Sleep(ting);

Beep(rel,ban);

Sleep(ting/2);

Beep(dol,ban);

Sleep(ting);

Beep(la,pai);

Sleep(ting);

Beep(dol,ban);

Sleep(ting/2);

Beep(rel,ban);

Sleep(ting);


Beep(dol,3*pai);

Sleep(ting);


Beep(la,pai+ban);

Sleep(ting);

Beep(dol,ban);

Sleep(ting);

Beep(si,ban);

Sleep(ting/2);

Beep(dol,ban);

Sleep(ting);

Beep(rel,ban);

Sleep(ting/2);

Beep(si,ban);

Sleep(ting);


Beep(so,3*pai);

Sleep(ting);


Beep(la,pai+ban);

Sleep(ting);

Beep(dol,ban);

Sleep(ting);

Beep(si,ban);

Sleep(ting/2);

Beep(dol,ban);

Sleep(ting);

Beep(rel,ban);

Sleep(ting/2);

Beep(so,ban);

Sleep(ting);


Beep(mi,pai);

Sleep(ting);

Beep(rel,ban);

Sleep(ting/2);

Beep(mil,ban);

Sleep(ting);

Beep(dol,2*pai);

Sleep(ting);


Beep(la,pai+ban);

Sleep(ting);

Beep(dol,ban);

Sleep(ting);

Beep(si,ban);

Sleep(ting/2);

Beep(dol,ban);

Sleep(ting);

Beep(rel,ban);

Sleep(ting/2);

Beep(si,ban);

Sleep(ting);



Beep(dol,pai);

Sleep(ting);

Beep(rel,ban);

Sleep(ting/2);

Beep(mil,ban);

Sleep(ting);

Beep(fal,2*pai);

Sleep(ting);


Beep(la,pai+ban);

Sleep(ting);

Beep(dol,ban);

Sleep(ting);

Beep(si,ban);

Sleep(ting/2);

Beep(dol,ban);

Sleep(ting);

Beep(rel,ban);

Sleep(ting/2);

Beep(si,ban);

Sleep(ting);


Beep(dol,2*pai);

Sleep(ting);

Sleep(pai);

Sleep(ting/2);

Beep(so,ban);

Sleep(ting);

Beep(dol,ban);

Sleep(ting/2);

Beep(rel,ban);

Sleep(ting);


Beep(dol,3*pai);

Sleep(1000);


main();


}


這是失敗的迷人的危險。。。

節奏不太對


include <cstdio>

#include <windows.h>

#define qdo 262

#define qre 294

#define qmi 330     //q字首為低音,1字尾為高音,s字首為半音階

#define qfa 349

#define qso 392

#define qla 440

#define qsi 494

#define do2 523

#define re 578

#define mi 659

#define fa 698

#define so 784

#define la 880

#define si 988

#define do1 1046

#define re1 1175

#define mi1 1318

#define fa1 1480

#define so1 1568

#define la1 1760

#define si1 1976

#define sqdo 277

#define sqre 311

#define sqfa 370

#define sqso 415

#define sqla 466

#define sdo 554

#define sre 622

#define sfa 740

#define sso 831

#define sla 932

#define sdo1 1046

#define sre1 1245

#define sfa1 1480

#define sso1 1661

#define sla1 1865


int main()

{

int pai=400,ban=200;

int ting=128;


Sleep(1000);


Beep(qla,ban/2);

Sleep(ting/4);

Beep(qsi,ban/2);

Sleep(ting/4);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(qsi,ban/2);

Beep(qsi,ban/2);

Sleep(ting/4);

Beep(qla,ban/2);

Sleep(ting/2);

Beep(qla,ban);

Beep(qla,ban/2);

Sleep(ting/2);

Beep(qsi,pai);

Sleep(ting);


Beep(qla,ban);

Sleep(ting/2);

Beep(qso,ban);

Beep(qso,2*pai);

Sleep(pai);

Sleep(pai);


Beep(qla,ban/2);

Sleep(ting/4);

Beep(qsi,ban/2);

Sleep(ting/4);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(qsi,ban/2);

Beep(qsi,ban/2);

Sleep(ting/4);

Beep(qla,ban/2);

Sleep(ting/2);

Beep(qla,ban);

Beep(qla,ban/2);

Sleep(ting/2);

Beep(qso,ban);

Sleep(ting);


Beep(qso,ban);

Sleep(ting/2);

Beep(mi,ban);

Beep(mi,2*pai);

Sleep(ting);

Sleep(ban);

Beep(re,ban/2);

Beep(do2,ban/2);

Beep(do2,ban/2);

Beep(qla,ban);

Sleep(ting/2);

Beep(qla,ban/2);

Sleep(ting);


Beep(mi,ban/2);

Sleep(ting/4);

Beep(re,ban/2);

Sleep(ting/4);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(mi,ban/2);

Beep(mi,ban);

Sleep(ting/2);

Beep(qla,ban/2);

Sleep(ting);

Beep(mi,ban/2);

Sleep(ting/4);

Beep(re,ban/2);

Sleep(ting/4);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(qso,ban/2);

Sleep(ting);


Beep(mi,ban);

Sleep(ting/2);

Beep(so,ban/2);

Sleep(ting/4);

Beep(so,ban/2);

Beep(so,ban);

Sleep(ting/2);

Beep(re,ban);

Sleep(ting);

Beep(do2,pai);

Sleep(ting);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(re,ban/2);

Sleep(ting/4);

Beep(mi,ban/2);

Sleep(ting/4);

Beep(mi,ban/2);

Beep(mi,ban);

Sleep(ting/2);

Beep(re,ban);

Sleep(ting);

Beep(re,ban);

Sleep(ting/2);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(re,ban/2);

Beep(re,pai);

Sleep(ting);


Beep(do2,ban/2);

Sleep(ting/4);

Beep(re,ban/2);

Sleep(ting/4);

Beep(mi,ban/2);

Sleep(ting/4);

Beep(mi,ban/2);

Beep(mi,ban);

Sleep(ting/2);

Beep(so,ban/2);

Sleep(ting);


Beep(so,ban);

Sleep(ting/2);

Beep(mi,ban/2);

Sleep(ting/4);

Beep(so,ban/2);

Beep(so,ban);

Sleep(ting);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(re,ban/2);

Sleep(ting/4);

Beep(mi,ban/2);

Sleep(ting/4);

Beep(mi,ban/2);

Beep(mi,ban);

Sleep(ting/2);

Beep(la,ban);

Sleep(ting);

Beep(la,ban);

Sleep(ting/2);

Beep(mi,ban);

Sleep(ting);

Beep(mi,ban);

Sleep(ting/2);

Beep(re,ban/2);

Sleep(ting/4);

Beep(re,ban/2);

Beep(re,ban/2);

Sleep(ting/4);

Beep(qsi,ban/2);

Sleep(ting/4);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(re,ban/2);

Sleep(ting);



Beep(re,ban);

Sleep(ting/2);

Beep(so,ban);

Sleep(ting);

Beep(so,ban);

Sleep(ting/2);

Beep(re,ban);

Sleep(ting);

Beep(re,ban);

Sleep(ting/2);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(do2,ban/2);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(qla,ban/2);

Sleep(ting/4);

Beep(qla,ban/2);

Sleep(ting/4);

Beep(qsi,ban/2);

Sleep(ting);


Beep(do2,ban);

Sleep(ting/2);

Beep(qsi,ban/2);

Sleep(ting/4);

Beep(do2,ban/2);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(qla,ban/2);

Sleep(ting/4);

Beep(qla,ban/2);

Sleep(ting/4);

Beep(qsi,ban/2);

Sleep(ting);

Beep(do2,ban);

Sleep(ting/2);

Beep(qsi,ban/2);

Sleep(ting/4);

Beep(do2,ban/2);

Beep(do2,ban);

Sleep(ting/2);

Beep(qso,ban);

Sleep(ting);


Beep(fa,pai);

Beep(fa,ban/2);

Sleep(ting/4);

Beep(mi,ban/2);

Sleep(ting/4);

Beep(re,ban/2);

Sleep(ting/4);

Beep(mi,ban/2);

Beep(mi,pai);

Sleep(ting);


Beep(do2,ban/2);

Sleep(ting/4);

Beep(re,ban/2);

Sleep(ting/4);

Beep(mi,ban/2);

Sleep(ting/4);

Beep(mi,ban/2);

Beep(mi,ban);

Sleep(ting/2);

Beep(la,ban/2);

Sleep(ting/4);

Beep(la,ban/2);

Beep(la,ban);

Sleep(ting/2);

Beep(mi,ban);

Sleep(ting);

Beep(mi,ban/2);

Sleep(ting/2);

Beep(fa,ban);

Sleep(ting/2);

Beep(re,ban/2);

Beep(re,ban/2);

Sleep(ting/4);

Beep(qsi,ban/2);

Sleep(ting/4);

Beep(qsi,ban/2);

Sleep(ting/4);

Beep(do2,ban/2);

Sleep(ting);


Beep(re,ban);

Sleep(ting/2);

Beep(si,ban);

Sleep(ting);

Beep(si,ban);

Sleep(ting/2);

Beep(so,ban);

Sleep(ting);


Beep(re,ban);

Sleep(ting/2);

Beep(do2,ban/2);

Sleep(ting/4);

Beep(do2,ban/2);

Beep(do2,ban);

Sleep(ting/2);

Beep(qla,ban/2);

Sleep(ting/4);

Beep(qsi,ban/2);


Sleep(1000);


main();


}



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69946337/viewspace-2682095/,如需轉載,請註明出處,否則將追究法律責任。

相關文章