同事都回家了,我无聊地Beep Beep了半天,分不多,散。。。
应该有前辈也这么干过吧?不懂音乐,简谱都看不懂,节拍是多长全靠感觉。
- C/C++ code
#include <iostream>using namespace std;const int DO = 261;const int RE = 293;const int MI = 329;const int FA = 349;const int SO = 392;const int LA = 440;const int TI = 493;const int DO_ = 130;const int RE_ = 147;const int MI_ = 165;const int FA_ = 174;const int SO_ = 186;const int LA_ = 220;const int TI_ = 247;int main(){ Beep(LA,300);//6 Beep(SO,100);//5 Beep(MI,300);//3 Beep(RE,100);//2 Beep(DO,400);//1 Beep(MI,300);//3 Beep(RE,100);//2 Beep(DO,200);//1 Beep(LA_,100);//6. Beep(SO_,400);//5. Beep(SO_,300);//5. Beep(LA_,100);//6. Beep(SO_,300);//5. Beep(LA_,100);//6. Beep(DO,300);//1 Beep(RE,100);//2 Beep(MI,200);//3 Beep(SO,200);//5 Beep(LA,300);//6 Beep(SO,100);//5 Beep(MI,100);//3 Beep(RE,100);//2 Beep(DO,200);//1 Beep(RE,400);//2 Beep(LA,300);//6 Beep(SO,100);//5 Beep(MI,300);//3 Beep(RE,100);//2 Beep(DO,400);//1 Beep(MI,300);//3 Beep(RE,100);//2 Beep(DO,200);//1 Beep(LA_,100);//6. Beep(SO_,400);//5. Beep(SO_,300);//5. Beep(LA_,100);//6. Beep(SO_,300);//5. Beep(LA_,100);//6. Beep(DO,300);//1 Beep(RE,100);//2 Beep(MI,200);//3 Beep(SO,200);//5 Beep(LA,300);//6 Beep(SO,100);//5 Beep(MI,100);//3 Beep(RE,100);//2 Beep(DO,200);//1 Beep(DO,400);//2 return 0;}
[解决办法]
[解决办法]
funny,新年快乐。
[解决办法]
[解决办法]
看同事回家,自己无聊接分了!
[解决办法]
无聊玩游戏啊
[解决办法]
[解决办法]
lz好雅兴,新年快乐,呵呵
[解决办法]
这个不错阿,弹出了程序员的心声,哈哈哈
[解决办法]
哈哈 各位新年快乐~~~~~~
[解决办法]
新手看不懂啊
[解决办法]
还不赶紧回家
[解决办法]
感觉挺好玩的。。嘿嘿~~
[解决办法]
咱都是同路人,上班坚守到最后,精神可嘉!大家新年快乐!
[解决办法]
看谱子是沧海一声笑嘛,哈哈~
[解决办法]
我也来凑下热闹,哈哈!
- C/C++ code
#include <windows.h>#include <iostream>#include <map>using namespace std;const int DO = 261;const int RE = 293;const int MI = 329;const int FA = 349;const int SO = 392;const int LA = 440;const int TI = 493;const int DO_ = 130;const int RE_ = 147;const int MI_ = 165;const int FA_ = 174;const int SO_ = 186;const int LA_ = 220;const int TI_ = 247;int frequency(char note){ static map<const char,int> table; if(table.size() == 0){ table['1'] = DO; table['2'] = RE; table['3'] = MI; table['4'] = FA; table['5'] = SO; table['6'] = LA; table['7'] = TI; table['c'] = DO_; table['d'] = RE_; table['e'] = MI_; table['f'] = FA_; table['g'] = SO_; table['a'] = LA_; table['b'] = TI_; } return table.find(note) -> second;}class music{ private: string notes; int tenuto; public: music(string &song , int tenuto_) { notes = song; tenuto = tenuto_; play(notes.end(),tenuto);} void play(string::iterator it,int duration );};void music::play(string::iterator it, int duration){ char note = *it; if( it == notes.begin() ) return; if( note == '-') play( it - 1, duration + tenuto); else { if( isalnum(note) ) { play( it - 1, 0); Beep(frequency(note), tenuto + duration); } else play( it - 1, duration); } } string bee = "\ 5 3 3 - | 4 2 2 - | 1 2 3 4 | 5 5 5 - | \ 5 3 3 - | 4 2 2 - | 1 3 5 5 | 3 3 3 - | \ 2 2 2 2 | 2 3 4 - | 3 3 3 3 | 3 4 5 - | \ 5 3 3 - | 4 2 2 - | 1 3 5 5 | 1 3 1 - | \ ";string happynewyear = "\1 1 1 - g - | 3 3 3 - 1 - | 1 3 5 - 5 - | \4 3 2 - - - | 2 3 4 - 4 - | 3 2 3 - 1 - | \1 3 2 - g - | b 2 1 - - - | \";int main(){ music m(bee, 300); music m2(happynewyear, 200); return 0;}
[解决办法]
啧啧,赞美
Beep是咋搞出来的?
我这咋编译不过去
[解决办法]
[解决办法]
可以啊
[解决办法]
不过咱的没有声音啊
[解决办法]
[解决办法]
祝lz和大家新年快乐
[解决办法]
哥你无聊到这种程度了我擦
[解决办法]
[解决办法]
楼主的歌写得不错哈:)
Happy Chinese New Year.
[解决办法]
楼主少#include <map>
#include <windows.h>
听不出啥
[解决办法]
[解决办法]
刚刚运行了一下,太奇妙了……学习了!
[解决办法]
[解决办法]
[解决办法]
[解决办法]
挺有意思
[解决办法]
e:\code\beep\beep.cpp(22) : error C2065: 'Beep' : undeclared identifier
[解决办法]
[解决办法]
拜年了。祝大家龙腾虎跃、龙马精神、龙年大吉!
[解决办法]
哈哈!我也玩过这个!
新年快乐。
[解决办法]
祝大家新春快乐! 学习代码中……
[解决办法]
新年快乐
------解决方案--------------------
不错,音乐潜力股
[解决办法]
半天没反应。。然后vc10崩溃了
[解决办法]
[解决办法]
新年快乐啊,LZ好雅兴
[解决办法]
哈哈 新年快乐 有趣
[解决办法]
龙年大吉!
[解决办法]
代码自在心中,敢问楼主,可是 笑傲江湖之曲?
[解决办法]
神曲
[解决办法]
读了个谱,沧海一声笑?这个帖子要发展成技术贴了
[解决办法]
呵呵,神曲!看不懂啊!
接啊!
[解决办法]
beep
beep
beeppppp
[解决办法]
好听急啦 那个牛人!!!
[解决办法]
[解决办法]
新年快乐