1. c語言編寫最高分和最低分
#include<stdio.h>
#defineSTUDENT_COUNT40 //定義學生數目
intmain()
{
intstudent_score[STUDENT_COUNT],max_score=0,min_score=100;
srand(unsigned(time(NULL)));
for(inti=0;i<STUDENT_COUNT;i++)
{
scanf("%d",&student_score[i]);
}
for(inti=0;i<STUDENT_COUNT;i++)
{
if(max_score<student_score[i])
{
max_score=student_score[i];
}
if(min_score>student_score[i])
{
min_score=student_score[i];
}
}
printf("maxscore:%d,minscore:%d ",max_score,min_score);
return0;
}
//測試樣例
//2
//4
//32
//91
//58
//67
//69
//31
//12
//88
//35
//40
//80
//87
//35
//61
//11
//67
//87
//67
//28
//70
//51
//8
//0
//50
//82
//25
//99
//74
//24
//48
//79
//85
//51
//13
//86
//19
//2
//41
//maxscore:99,minscore:0
2. C語言struct程序輸出最高分
#include<stdio.h>
structstudent
{
intnum;
charname[10];
intscore;
}student[5],S;
voidmain()
{
inti;
printf("輸入五個學生的學號,名字,成績 ");
for(i=0;i<5;i++)
{
scanf("%d%s%d",&student[i].num,&student[i].name,&student[i].score);
}
S=student[0];
for(i=1;i<5;i++)
{
if(S.score<student[i].score)
S=student[i];
}
printf(" 第一名學生的信息:");
printf(" 學號:%d 姓名:%s 成績:%d ",S.num,S.name,S.score);
}
這個程序不用取下標那麼麻煩,定義結構體S就可以了
3. C語言編程 查找最高總分
#include<stdio.h>
#defineN5
intmain()
{
charstr[N][20]={'