下面用beep函式發音,按鍵 1,2,3,4,5,6,7,8 對應 多來米發少。。。
按換行鍵結束。0.3秒一個音,不要按得太快。
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
char p;
int i=0;
printf("input 12345678..\n");
while ( i < 50 ){
p = getch();
if (p == "\r") break;
switch(p-"0"){
case 1: Beep(523,300);break;
case 2: Beep(587,300);break;
case 3: Beep(659,300);break;
case 4: Beep(698,300);break;
case 5: Beep(784,300);break;
case 6: Beep(880,300);break;
case 7: Beep(980,300);break;
case 8: Beep(1060,300);break;
default: break;
}
i++;
exit(0);
下面用beep函式發音,按鍵 1,2,3,4,5,6,7,8 對應 多來米發少。。。
按換行鍵結束。0.3秒一個音,不要按得太快。
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
char p;
int i=0;
printf("input 12345678..\n");
while ( i < 50 ){
p = getch();
if (p == "\r") break;
switch(p-"0"){
case 1: Beep(523,300);break;
case 2: Beep(587,300);break;
case 3: Beep(659,300);break;
case 4: Beep(698,300);break;
case 5: Beep(784,300);break;
case 6: Beep(880,300);break;
case 7: Beep(980,300);break;
case 8: Beep(1060,300);break;
default: break;
}
i++;
}
exit(0);
}