展开全部
编译能通过---------- 编译时把注释去掉
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct song{ //定义一个歌曲结构
int id; //歌曲号
char title[20]; //歌曲名
char singer[20]; //歌手名
};
typedef struct song SONG; //把结构命名为 SONG
int main( void )
{
SONG songlist[100]; //定义一个存储歌曲信息的列表,长100
int i=0,j;
int c;
clrscr();
while (i<=100) {
printf( "please enter the song's id, title and singer:\n" );
//输入歌曲号 然后空格 输入歌曲名 然后空格 输入歌手名 然后回车
scanf( "%d%s%s", &songlist[i].id, songlist[i].title, songlist[i].singer);
i++;
//每次输入完一条信息后,把列表中的歌曲信息全部打印出来看一下
printf("the songlist is below:\n\n");
for( j=0; j<=i; j++){
printf( "%d %s %s\n", songlist[j].id, songlist[j].title, songlist[j].singer );
}
printf("\n");
}
getch();
return 0;
}
或者是
#include "dos.h"
#include "stdio.h"
#define time 10000 /*预定义节拍长度 time(一拍)*/
#define time0 5000 /*预定义半节拍长度 time0*/
#define time1 15000 /*预定义1.5节拍长度 time1*/
#define time2 20000 /*预定义2节拍长度 time2*/
#define time3 30000 /*预定义3节拍长度 time3*/
#define _a 262 /*预定义低音音符1~7*/
#define _b 294
#define _c 330
#define _d 349
#define _e 392
#define _f 440
#define _g 494
#define a 523/*预定义中音音符1~7*/
#define b 587
#define c 659
#define d 698
#define e 784
#define f 880
#define g 988
#define a_ 1047/*预定义高音音符1~7*/
#define b_ 1175
#define c_ 1319
#define d_ 1397
#define e_ 2568
#define f_ 1760
#define g_ 1976
main()
{
int i=0,j;
unsigned milliseconds;
int music[1000]={
f,time,
f,time,
g,time0,
f,time,
f,time,
g,time0,
f,time,
g,time,
a_,time,
g,time,
f,time,
g,time0,
f,time0,
d,time,
c,time,
a,time,
c,time,
d,time,
c,time,
c,time0,
a,time0,
_g,time,
f,time,
g,time,
a_,time,
g,time,
f,time,
g,time0,
f,time0,
d,time1,
c,time,
a,time,
c,time,
d,time,
c,time,
c,time0,
a,time0,
g,time1,
f,time,
f,time,
g,time1,
f,time,
f,time,
g,time1,
c,time,
d,time,
g,time0,
f,time0,
c,time,
d,time,
g,time0,
f,time0,
d,time0,
d,time,
c,time3
}
;
while(music[i]!='\0')
{
if(music[i]<=494) /*判断不是低音*/
{
milliseconds=music[i+1];
for(j=1;j<8;j++)
{
switch(j)
{
case 1: sound(a);
delay(milliseconds);break;
case 2: sound(b);
delay(milliseconds);break;
case 3: sound(c);
delay(milliseconds);break;
case 4: sound(d);
delay(milliseconds);break;
case 5: sound(e);
delay(milliseconds);break;
case 6: sound(f);delay(milliseconds);break;
case 7: sound(g);
delay(milliseconds);break;
}
nosound();
}
}
if(music[i]>494&&music[i]<988) /*判断不是中音*/
{
milliseconds=music[i+1];
for(j=1;j<8;j++)
{
switch(j)
{
case 1: sound(_a);
delay(milliseconds);break;
case 2: sound(_b);
delay(milliseconds);break;
case 3: sound(_c);
delay(milliseconds);break;
case 4: sound(_d);
delay(milliseconds);break;
case 5: sound(_e);
delay(milliseconds);break;
case 6: sound(_f);
delay(milliseconds);break;
case 7: sound(_g);
delay(milliseconds);break;
}
nosound();
}
}
if(music[i]>988) /*判断不是高音*/
{
milliseconds=music[i+1];
for(j=1;j<8;j++)
{
switch(j)
{
case 1: sound(a_);
delay(milliseconds);break;
case 2: sound(b_);
delay(milliseconds);break;
case 3: sound(c_);
delay(milliseconds);break;
case 4: sound(d_);
delay(milliseconds);break;
case 5: sound(e_);
delay(milliseconds);break;
case 6: sound(f_);
delay(milliseconds);break;
case 7: sound(g_);
delay(milliseconds);break;
}
nosound();
}
}
nosound();
i=i+2;
}
}
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct song{ //定义一个歌曲结构
int id; //歌曲号
char title[20]; //歌曲名
char singer[20]; //歌手名
};
typedef struct song SONG; //把结构命名为 SONG
int main( void )
{
SONG songlist[100]; //定义一个存储歌曲信息的列表,长100
int i=0,j;
int c;
clrscr();
while (i<=100) {
printf( "please enter the song's id, title and singer:\n" );
//输入歌曲号 然后空格 输入歌曲名 然后空格 输入歌手名 然后回车
scanf( "%d%s%s", &songlist[i].id, songlist[i].title, songlist[i].singer);
i++;
//每次输入完一条信息后,把列表中的歌曲信息全部打印出来看一下
printf("the songlist is below:\n\n");
for( j=0; j<=i; j++){
printf( "%d %s %s\n", songlist[j].id, songlist[j].title, songlist[j].singer );
}
printf("\n");
}
getch();
return 0;
}
或者是
#include "dos.h"
#include "stdio.h"
#define time 10000 /*预定义节拍长度 time(一拍)*/
#define time0 5000 /*预定义半节拍长度 time0*/
#define time1 15000 /*预定义1.5节拍长度 time1*/
#define time2 20000 /*预定义2节拍长度 time2*/
#define time3 30000 /*预定义3节拍长度 time3*/
#define _a 262 /*预定义低音音符1~7*/
#define _b 294
#define _c 330
#define _d 349
#define _e 392
#define _f 440
#define _g 494
#define a 523/*预定义中音音符1~7*/
#define b 587
#define c 659
#define d 698
#define e 784
#define f 880
#define g 988
#define a_ 1047/*预定义高音音符1~7*/
#define b_ 1175
#define c_ 1319
#define d_ 1397
#define e_ 2568
#define f_ 1760
#define g_ 1976
main()
{
int i=0,j;
unsigned milliseconds;
int music[1000]={
f,time,
f,time,
g,time0,
f,time,
f,time,
g,time0,
f,time,
g,time,
a_,time,
g,time,
f,time,
g,time0,
f,time0,
d,time,
c,time,
a,time,
c,time,
d,time,
c,time,
c,time0,
a,time0,
_g,time,
f,time,
g,time,
a_,time,
g,time,
f,time,
g,time0,
f,time0,
d,time1,
c,time,
a,time,
c,time,
d,time,
c,time,
c,time0,
a,time0,
g,time1,
f,time,
f,time,
g,time1,
f,time,
f,time,
g,time1,
c,time,
d,time,
g,time0,
f,time0,
c,time,
d,time,
g,time0,
f,time0,
d,time0,
d,time,
c,time3
}
;
while(music[i]!='\0')
{
if(music[i]<=494) /*判断不是低音*/
{
milliseconds=music[i+1];
for(j=1;j<8;j++)
{
switch(j)
{
case 1: sound(a);
delay(milliseconds);break;
case 2: sound(b);
delay(milliseconds);break;
case 3: sound(c);
delay(milliseconds);break;
case 4: sound(d);
delay(milliseconds);break;
case 5: sound(e);
delay(milliseconds);break;
case 6: sound(f);delay(milliseconds);break;
case 7: sound(g);
delay(milliseconds);break;
}
nosound();
}
}
if(music[i]>494&&music[i]<988) /*判断不是中音*/
{
milliseconds=music[i+1];
for(j=1;j<8;j++)
{
switch(j)
{
case 1: sound(_a);
delay(milliseconds);break;
case 2: sound(_b);
delay(milliseconds);break;
case 3: sound(_c);
delay(milliseconds);break;
case 4: sound(_d);
delay(milliseconds);break;
case 5: sound(_e);
delay(milliseconds);break;
case 6: sound(_f);
delay(milliseconds);break;
case 7: sound(_g);
delay(milliseconds);break;
}
nosound();
}
}
if(music[i]>988) /*判断不是高音*/
{
milliseconds=music[i+1];
for(j=1;j<8;j++)
{
switch(j)
{
case 1: sound(a_);
delay(milliseconds);break;
case 2: sound(b_);
delay(milliseconds);break;
case 3: sound(c_);
delay(milliseconds);break;
case 4: sound(d_);
delay(milliseconds);break;
case 5: sound(e_);
delay(milliseconds);break;
case 6: sound(f_);
delay(milliseconds);break;
case 7: sound(g_);
delay(milliseconds);break;
}
nosound();
}
}
nosound();
i=i+2;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询