Y15BeTa蜂鸣器唱歌程序-演奏版
生活随笔
收集整理的這篇文章主要介紹了
Y15BeTa蜂鸣器唱歌程序-演奏版
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
最優(yōu)版,自由演奏你的音樂!
每天進步一點點!
2018-12-09最新版
#include<bits/stdc++.h>
#include<windows.h> using namespace std; int md[8]={0,262,294,330,349,392,440,494}, mz[8]={0,523,587,659,698,784,880,988}, mg[8]={0,1046,1175,1318,1397,1568,1760,1967}; int tot=0; inline void gotoxy(int y,int x); inline void open(); inline int pinglv(string s); inline void ywy_beep(string s); //inline void change_start_music(); inline void gotoxy(int y,int x){ COORD pos; pos.X=x; pos.Y=y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos); } inline void ywy_beep(string s){ if(s=="cls"){ tot=0; system("cls"); return; } else if(s[0]=='B'){//手動,半調(diào)及連長音暫時只能用此解決 string a;int b; cin>>a>>b; int p=pinglv(a); if(p!=0)Beep(p,b); else{ int ia=0; for(int i=0;i<=a.size()-1;i++)ia=ia*10+int(a[i])-48; Beep(ia,b); } } else if(s=="rand"){ printf("請輸入持續(xù)時間(單位:秒)\n"); int ha; scanf("%d",&ha); ha*=5; while(ha--)Beep(abs((rand()+ha*ha)%1500),200); } else if(s[0]=='&'){//微調(diào):換氣或隔音 Sleep(50); } else if(s[0]=='0'){//休止符 Sleep(300); } else{ int p=pinglv(s); if(p!=0){ Beep(p,300); } else{ cout<<"震驚*"<<++tot; for(int i=1;i<=tot;i++)cout<<'!'; cout<<endl; } } } inline void open(){ gotoxy(11,30); printf("歡迎進入演奏系統(tǒng)\n"); for(int i=1;i<=3*88889999;i++); gotoxy(24,0); Beep(mz[1],180); Beep(mz[2],190); Beep(mz[3],200); Beep(mz[4],210); Beep(mz[5],700); printf("加載中"); for(int i=1;i<=70;i++){ printf(">"); Sleep(10); } system("cls"); system("pause"); printf("\n\n指引: cls可以清除我的所有記憶:)\n\n祝旅途愉快!\n\n");// system("pause"); } inline int pinglv(string s){ if(s[0]>='1'&&s[0]<='7'&&s.size()==1){//中音 int ha=int(s[0]-'0'); return mz[ha]; } else if(s[0]=='d'&&s[1]>='1'&&s[1]<='7'&&s.size()==2){//低音 int ha=int(s[1]-'0'); return md[ha]; } else if(s[0]=='g'&&s[1]>='1'&&s[1]<='7'&&s.size()==2){//高音 int ha=int(s[1]-'0'); return mg[ha]; } else return 0; } int main(){ srand(time(0)); open(); while(1){ string s; cin>>s; ywy_beep(s); } }
轉(zhuǎn)載于:https://www.cnblogs.com/Y15BeTa/p/FengMingQi__1.html
總結(jié)
以上是生活随笔為你收集整理的Y15BeTa蜂鸣器唱歌程序-演奏版的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 软包一般多少钱一个平方
- 下一篇: 求小老鼠上灯台歌词。