数据a[n],把n个数赋值给a[0]到a[n-1],然后循环找出最低分,最高分,循环数组(a[0]+a[1]++a[n-1]-最高分-最低分)/n就是最后的平局分,思路给你,自己写吧,很简单。
#include <reg51h> //包括一个51标准内核的头文件
#define uchar unsigned char //定义一下方便使用
#define uint unsigned int
sbit BEEP=P3^6; //喇叭输出脚
uchar th0_f; //在中断中装载的T0的值高8位
uchar tl0_f; //在中断中装载的T0的值低8位
/ 延时 1ms /
void delay_1ms(unsigned int t)
{
unsigned char i,j;
for(t;t>0;t--)
{
for(i=34;i>0;i--)
for(j=13;j>0;j--);
}
}
//T0的值,及输出频率对照表
static code freq[36][2] = {
0xA9,0xEF, //00220HZ ,1 //0
0x93,0xF0, //00233HZ ,1# //1
0x73,0xF1, //00247HZ ,2 //2
0x49,0xF2, //00262HZ ,2# //3
0x07,0xF3, //00277HZ ,3 //4
0xC8,0xF3, //00294HZ ,4 //5
0x73,0xF4, //00311HZ ,4# //6
0x1E,0xF5, //00330HZ ,5 //7
0xB6,0xF5, //00349HZ ,5# //8
0x4C,0xF6, //00370HZ ,6 //9
0xD7,0xF6, //00392HZ ,6# //10
0x5A,0xF7, //00415HZ ,7 //11
0xD8,0xF7, //00440HZ 1 //12
0x4D,0xF8, //00466HZ 1# //13
0xBD,0xF8, //00494HZ 2 //14
0x24,0xF9, //00523HZ 2# //15
0x87,0xF9, //00554HZ 3 //16
0xE4,0xF9, //00587HZ 4 //17
0x3D,0xFA, //00622HZ 4# //18
0x90,0xFA, //00659HZ 5 //19
0xDE,0xFA, //00698HZ 5# //20
0x29,0xFB, //00740HZ 6 //21
0x6F,0xFB, //00784HZ 6# //22
0xB1,0xFB, //00831HZ 7 //23
0xEF,0xFB, //00880HZ `1 //24
0x2A,0xFC, //00932HZ `1# //25
0x62,0xFC, //00988HZ `2 //26
0x95,0xFC, //01046HZ `2# //27
0xC7,0xFC, //01109HZ `3 //28
0xF6,0xFC, //01175HZ `4 //29
0x22,0xFD, //01244HZ `4# //30
0x4B,0xFD, //01318HZ `5 //31
0x73,0xFD, //01397HZ `5# //32
0x98,0xFD, //01480HZ `6 //33
0xBB,0xFD, //01568HZ `6# //34
0xDC,0xFD, //01661HZ `7 //35
};
static code music1[464] = { // 《隐形的翅膀》
36,36,36,36,36,36,36,36,36,36,36,36,8,8,12,12, //每一
16,16,16,16,16,16,19,19,16,16,16,16,14,14,12,12, //次都在徘徊
12,12,12,12,12,12,9,9,8,8,8,36,9,9,12,12, //孤单中坚强 每一
16,16,16,16,16,16,19,19,19,19,19,19,21,21,19,19, //次就算很受伤
19,19,16,16,14,14,12,12,14,14,14,36,21,21,19,19, //也不闪泪光 我知
16,16,16,16,16,16,19,19,19,19,19,19,21,21,19,19, //道我一直有双
16,16,14,14,12,12,14,14,9,9,9,36,8,8,9,9, //隐形的翅膀 带我
12,12,12,12,12,12,16,16,14,14,14,14,16,14,14,14, //飞 飞过绝
12,12,12,12,12,12,12,12,12,12,12,36,8,8,12,12, //望 不去
16,16,16,16,16,16,19,19,16,16,16,16,14,14,12,12, //想他们拥有
12,12,12,12,12,12,9,9,8,8,8,36,8,8,12,12, //美丽的太阳 我看
16,16,16,16,16,16,19,19,19,19,19,19,21,21,19,19, //见每天的夕阳
19,19,16,16,14,14,12,12,14,14,14,36,21,21,19,19, //也会有变化 我知
16,16,16,16,16,16,19,19,19,19,19,19,21,21,19,19, //道我一直有双
16,16,14,14,12,12,14,14,9,9,9,36,8,8,9,9, //隐形的翅膀 带我
12,12,12,12,12,12,14,16,14,14,14,14,16,16,12,12, //飞 给我希
12,12,12,12,12,12,12,12,12,12,12,36,16,16,19,19, //望 我终
24,24,24,24,24,36,24,24,24,24,24,24,21,21,19,19, //于看到所有
21,21,24,24,16,16,14,14,12,12,12,36,12,12,12,12, //梦想都开花 追逐
12,12,24,24,24,24,21,21,19,19,16,16,14,14,12,12, //的年轻歌声多嘹
14,14,14,14,14,14,14,14,14,14,14,36,16,16,19,19, //亮 我终
24,24,24,24,24,36,24,24,24,24,24,24,21,21,19,19, //于翱翔用心
21,21,24,24,16,16,14,14,12,12,12,36,12,12,12,12, //凝望不害怕 哪里
12,12,24,24,24,24,21,21,19,19,16,16,14,14,12,12, //会有风就飞多远
12,12,12,12,12,12,12,12,12,12,36,36,16,16,19,19, //吧 隐形
24,24,24,24,24,36,24,24,23,23,23,23,21,21,19,19, //的翅膀让梦
21,21,24,24,16,16,14,14,12,12,12,36,12,12,12,12, //恒久比天长 留一
12,12,24,24,24,24,21,21,19,19,16,16,14,14,14,14, //个愿望让自己
14,14,14,14,12,12,12,12,12,12,12,12,12,12,12,36, //想象
};
static code music2[336] = { // 《北京欢迎你》
16,16,19,19,16,16,14,14,16,16,14,14,16,16,16,36, //迎接另一个晨曦
16,16,14,14,9,9,12,12,16,16,14,14,14,14,14,36, //带来全新空气
14,14,12,12,9,9,12,12,14,14,16,16,19,19,14,14, //气息改变情味不变
16,16,21,21,19,19,9,9,14,14,12,12,12,12,12,36, //茶香飘满情谊
16,16,19,19,16,16,14,14,16,16,14,14,16,16,16,36, //我家大门常打开
16,16,14,14,9,9,12,12,16,16,14,14,14,14,14,36, //开放怀抱等你
14,14,12,12,9,9,12,12,14,14,16,16,19,19,14,14, //拥抱过就有了默契
16,16,21,21,19,19,9,9,14,14,12,12,12,12,12,36, //你会爱上这里
14,14,12,12,9,9,12,12,14,14,16,16,19,19,14,14, //不管远近都是客人
16,16,21,21,19,19,19,19,16,16,16,16,16,16,16,36, //请不用客气
14,14,16,16,14,14,12,12,19,19,21,21,14,14,14,36, //相约好了在一起
9,9,16,16,14,14,14,14,12,12,12,12,12,12,12,36, //我们欢迎你
36,36,36,36,36,36,36,36,16,16,16,16,19,19,19,19, //北京
24,24,19,19,21,21,21,21,36,36,21,21,19,19,16,16, //欢迎你 为你开
16,16,19,19,19,19,19,19,19,19,19,36,16,16,19,19, //天辟地 流动
21,21,24,24,26,26,24,24,19,19,16,16,14,14,19,19, //中的魅力充满着朝
16,16,16,16,16,16,16,16,16,16,16,36,16,16,19,19, //气 北京
24,24,19,19,21,21,21,21,36,36,24,24,26,26,24,24, //欢迎你 在太阳
19,19,16,16,19,19,23,23,21,21,21,21,36,36,16,16, //下分享呼吸 在
14,14,16,16,19,19,28,28,26,26,26,26,26,26,23,23, //黄土地刷新成
24,24,24,24,24,24,24,24,24,24,24,24,24,24,36,36, //绩
};
static code music3[444] = { // 《仙剑奇侠传》
28,28,26,26,28,28,28,28,28,28,21,21,
26,26,26,26,24,24,23,23,21,21,21,23,21,21,19,19,
28,28,28,28,16,16,19,19,24,24,24,24,16,16,19,19,
26,26,26,26,24,24,23,23,21,21,21,21,21,21,21,21,
21,21,21,21,28,28,26,26,36,36,36,36,28,28,26,26,
21,21,21,21,24,24,26,26,28,28,28,28,28,28,28,28,
28,28,31,31,28,28,24,24,26,26,26,26,26,26,26,26,
21,21,21,21,24,24,28,28,26,26,26,26,24,24,24,24,
21,21,21,21,21,21,21,21,21,21,21,21,36,36,36,36,
28,28,26,26,28,28,28,28,28,28,21,21,
26,26,26,26,24,24,23,23,21,21,21,23,21,21,19,19,
28,28,28,28,16,16,19,19,24,24,24,24,16,16,19,19,
26,26,26,26,28,24,23,23,21,21,21,21,21,21,21,21,
21,21,21,21,28,28,26,26,36,36,36,36,28,28,26,26,
28,28,28,28,28,28,21,21,
26,26,26,26,24,24,23,23,21,21,21,23,21,21,19,19,
16,16,16,16,16,16,19,19,24,24,24,24,16,16,19,19,
26,26,26,26,28,24,23,23,21,21,21,21,21,21,21,21,
21,21,21,21,23,23,23,23,23,23,23,23,23,23,23,23,
21,21,21,21,24,24,26,26,28,28,28,28,28,28,28,28,
31,33,31,31,28,28,24,24,26,26,26,26,26,26,26,26,
21,21,21,21,24,24,28,28,26,26,26,26,24,24,24,24,
21,21,21,21,21,21,21,21,21,21,21,21,36,36,36,36,
28,28,26,26,28,28,28,28,28,28,21,21,
26,26,26,26,24,24,23,23,21,21,21,23,21,21,19,19,
28,28,28,28,16,16,19,19,24,24,24,24,16,16,19,19,
26,26,26,26,28,24,23,23,21,21,21,21,21,21,21,21,
23,23,23,23,23,23,23,23,23,23,23,23,21,21,19,19,
21,21,21,21,21,21,21,21,36,36,36,36,36,36,36,36,
};
static code music4[448] = { // 《笑傲江湖》
16,16,16,16,21,21,21,16,19,19,19,19,19,19,16,16,
14,14,16,16,19,19,21,21,16,16,16,16,16,16,16,36,
16,16,16,16,21,21,21,16,19,19,19,19,19,19,16,16,
14,14,16,16,19,19,21,19,16,16,16,16,36,16,16,14,
12,12,12,12,14,14,16,16,14,14,14,14,14,14,14,12,
9,9,9,12,14,14,16,16,19,19,19,21,19,19,16,14,
12,12,12,14,14,14,16,16,14,14,14,14,14,12,12,12,
9,9,9,12,14,16,16,19,21,21,21,21,21,21,21,36,
16,16,16,16,21,21,21,16,19,19,19,19,19,19,16,16,
14,14,16,16,19,19,21,19,16,16,16,16,16,16,16,36,
16,16,16,16,21,21,21,16,19,19,19,19,19,19,16,16,
14,14,14,16,19,19,21,19,16,16,16,16,36,16,16,14,
12,12,12,12,14,14,16,16,14,14,14,14,14,14,14,12,
9,9,9,12,14,14,16,16,19,19,19,21,19,19,16,14,
12,12,12,14,14,14,16,16,14,14,14,14,14,12,12,12,
9,9,9,12,14,16,16,19,21,21,21,21,21,21,21,36,
14,14,14,14,14,16,16,14,12,12,12,12,12,9,9,12,
14,14,14,14,14,16,16,14,12,12,9,9,36,12,9,12,
14,14,14,14,14,16,16,14,12,12,12,12,36,12,9,12,
14,14,14,14,14,19,19,16,16,16,16,16,16,16,16,36,
9,9,9,9,36,9,9,9,14,14,14,14,14,14,16,14,
12,12,12,12,36,12,12,14,9,9,9,9,9,9,7,7,
9,9,9,9,36,9,7,7,4,4,4,4,36,4,7,7,
2,2,2,2,36,2,2,2,4,4,4,4,4,4,4,36,
9,9,9,9,9,9,9,9,14,14,14,14,14,14,16,16,
12,12,12,12,12,12,14,14,9,9,9,9,12,9,
7,7,7,7,7,7,9,9,4,4,4,2,4,4,7,7,
9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
};
//定时中断0,用于产生唱歌频率
timer0() interrupt 1
{
TL0=tl0_f;TH0=th0_f; //调入预定时值
BEEP=~BEEP; //取反音乐输出IO
P2=~P2;
}
//音阶声音自动输出试验
void main(void) // 主程序
{
uint i;
TMOD = 0x01; //使用定时器0的16位工作模式
TR0 = 1;
ET0 = 1;
EA = 1;
while(1)
{
for(i=0;i<336;i++) //播放音乐
{
if(music2[i] == 36) //空音
{
TR0 = 0;
delay_1ms(190);
TR0 = 1;
}
else
{
tl0_f=freq[music2[i]][0]; //置一个音符的值
th0_f=freq[music2[i]][1];
delay_1ms(190);
}
}
TR0 = 0;
delay_1ms(3000);
TR0 = 1;
}
}
#include "stdioh"
void main()
{
int i,Max=-1,Min=999,Score,x,y;
double Sum=0,a[10],Max2=-1,Min2=999,z;
printf("练习30题_6:歌星比赛评分:\n");
for(i=1;i<=10;i++)
{
printf("第%d位评委打分:\n",i);
scanf("%d",&Score);
a[i]=Score;
Sum+=Score;
if(Score>Max)Max=Score;
if(Score<Min)Min=Score;
}
printf("%s%d\n%s%d\n%s%f\n","去掉一个最高分",Max,"去掉一个最低分",Min,"得出的分数为:",(Sum-Min-Max)/8);
z=(Sum-Min-Max)/8;
for(i=1;i<=10;i++)
{
if(a[i]-z>0)//等于0就是差距最小的了所以不用在max上
if(a[i]-z>Max2)
{
Max2=a[i]-z;
x=i;
}
else if (z-a[i]>0)
if(z-a[i]>Max2)
{
Max2=z-a[i];
x=i;
}
if(a[i]-z>=0)
if(a[i]-z<Min2)
{
Min2=a[i]-z;
y=i;
}
else if (z-a[i]>=0)
if(z-a[i]<Min2)
{
Min2=z-a[i];
y=i;
}
}
printf("思维延伸:最公平的裁判是:第%d位。\n最不公平的裁判是:第%d位。\n",y,x);//以上代码没写并列情况
}
用VC++编译通过,代码如下(其中awav为自己给出):
#include<windowsh>
#pragma comment(lib,"winmmlib")
void main()
{
PlaySound("C:\\awav",0,SND_FILENAME|SND_SYNC);
}
编译能通过---------- 编译时把注释去掉
#include<stdioh>
#include<stdlibh>
#include<stringh>
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 "dosh"
#include "stdioh"
#define time 10000 /预定义节拍长度 time(一拍)/
#define time0 5000 /预定义半节拍长度 time0/
#define time1 15000 /预定义15节拍长度 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<windowsh>
#define N 14
enum FREQUENCY{
Fc=131, Fd=147, Fe=165, Ff=175, Fg=196, Fa=220, Fb=247,
Fc1=262, Fd1=294, Fe1=330, Ff1=349, Fg1=392, Fa1=440, Fb1=494
};
int gamut[N]={ Fc, Fd, Fe, Ff, Fg, Fa, Fb, Fc1, Fd1, Fe1, Ff1, Fg1, Fa1, Fb1 };
int main()
{
int i;
for(i=0; i<N; i++)
Beep( gamut[i], 300);
return 0;
}
以上就是关于C语言编程题,有N个评委,对唱歌比赛选手现场评分~~ 急啊!!全部的内容,包括:C语言编程题,有N个评委,对唱歌比赛选手现场评分~~ 急啊!!、怎么把歌曲用单片机C语言程序进行播放,急急急急~~~~~~、用C语言编写一个歌唱比赛成绩统计程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)