这段程序哪里错了
- 提问者网友:辞取
- 2021-04-25 04:14
#include<dos.h>
void pause(int);
void soundl(int int);
void main(void)
{
int i,freq,speed=5;
int time=4+speed;
char *qm="iddgwwwqqgfff dddfghhhggg ddgwwwqqgfff\
ddffhjqqqq wpggjhgddgqq hhqwwqjjjggg\
ddgwwwqqqgfff ddffhjqqqqqq"
while(*qm++!='\0')
{
i=1;
switch(*qn)
{
case'k':
tine=1*speed;i=0;break;
case 'i':
time=6*speed;i=0;break;
case'o':
time=10*speed;i=0;break;
case'p':
pause(time);i=0;break;
case'a':
freq=523;break;
case's':
freq=587;break;
case'd':
freq=659;break;
case'f':
freq=698;break;
case'g':
freq=784;break;
case'h';
freq=880;break;
case'j':
freq=988;break;
case'z':
freq=262;break;
case 'x':
freq=296;break;
case'c':
freq=330;break;
case'c':
freq=330;break;
case'v':
freq=349;break;
case'b':
freq=392;break;
case'n':
freq=440;break;
case'm':
freq=494;break;
case'q':
freq=1047;break;
case'w':
freq=1175;break;
case'e':
freq=1319;break;
case'r':
freq=1397;break;
case't':
freq=2568;break;
case'y':
freq=1760;break;
case'u':
freq=1976;break;
default:
i=0;break;
}
if(i)
sounl(freq,time);
}
}
void soundl(int freq int time)
{
union
{
long divison;
unsigned char c[2];
} ;count
unsigned char ch
count.divisor=1193280/freq;
outp(67,182);
outp(66,count.c[0]);
outp(66,count.c[1]);
ch=inp(97);
outp(97,ch(3));
pause(time);
outp(97,ch);
}
void pause(int time)
{
int t1,t2;
union REGS in out;
in.h.ar=OX2c;
int86(OX2c,&in,&out);
t1=t2=100*out,h.dh+out.h.dl;
while(t2-t1<time)
{
int86(OX21,&in,&out);
t2=100*out.h.oh+out.h.dl;
if(t2<t1)t2+=6000
}
}
- 五星知识达人网友:人類模型
- 2021-04-25 05:39
第一 "void soundl(int int);“ int 中间少逗号。应为void soundl(int, int);
第二 "char *qm="iddgwwwqqgfff dddfghhhggg ddgwwwqqgfff\
ddffhjqqqq wpggjhgddgqq hhqwwqjjjggg\
ddgwwwqqqgfff ddffhjqqqqqq"" 少语句结束的;
第三 switch(*qn)变量敲错了,应为switch(*qm)
第四 "case'k':
tine=1*speed;i=0;break;" 中tine敲错了,应为Time
第五 case'h';中的分号应为冒号
第六 case'c':
freq=330;break;重复了,要删除一个
第七 void soundl(int freq int time)两个形参之间加逗号
给你一个完整程序自己看吧。怎么照抄都能抄出这么多错来。
#include<stdio.h>
#include<dos.h>
void pause(int);
void soundl(int, int);
void main(void)
{
int i,freq,speed=5;
int time=4+speed;
char *qm="iddgwwwqqgfff dddfghhhggg ddgwwwqqgfff\ ddffhjqqqq wpggjhgddgqq hhqwwqjjjggg\ ddgwwwqqqgfff ddffhjqqqqqq";
while(*qm++!='\0')
{
i=1;
switch(*qm)
{
case'k':
time=1*speed;i=0;break;
case 'i':
time=6*speed;i=0;break;
case'o':
time=10*speed;i=0;break;
case'p':
pause(time);i=0;break;
case'a':
freq=523;break;
case's':
freq=587;break;
case'd':
freq=659;break;
case'f':
freq=698;break;
case'g':
freq=784;break;
case'h':
freq=880;break;
case'j':
freq=988;break;
case'z':
freq=262;break;
case 'x':
freq=296;break;
case'c':
freq=330;break;
case'v':
freq=349;break;
case'b':
freq=392;break;
case'n':
freq=440;break;
case'm':
freq=494;break;
case'q':
freq=1047;break;
case'w':
freq=1175;break;
case'e':
freq=1319;break;
case'r':
freq=1397;break;
case't':
freq=2568;break;
case'y':
freq=1760;break;
case'u':
freq=1976;break;
default:
i=0;break;
}
if(i)
sounl(freq,time);
}
}
void sound1(int freq,int time)
{
union{
long divisor;
unsigned char c[2];
}count;
unsigned char ch;
count.divisor=1193280/freq;
outp(67,182);
outp(66,count.c[0]);
outp(66,count.c[1]);
ch=inp(97);
outp(97,ch|3);
pause(time);
outp(97,ch);
}
void pause(int time)
{
int t1,t2;
union REGS in,out;
in.h.ah=0x2c;
int86(0x21,&in,&out);
t1=t2=100*out.h.dh+out.h.dl;
while(t2-t1<time)
{
int86(0x21,&in,&out);
t2=100*out.h.dh+out.h.dl;
if (t2<t1)t2+=6000;
}
}
- 1楼网友:醉吻情书
- 2021-04-25 06:11