<stdio.h>
void
main()
{
int
i,
n,
reno
float
score[30],
avr,
a,
b,
c
char
name[30][9]
for(i
=
0
i
<
30
i++)
{
printf("%d号的成绩:",
i+1)
scanf("%f",
&score[i])
if(score[i]
<
0)
break
printf("%d号的姓名:",
i+1)
scanf("%s",
name[i])
}
n
=
i
printf("统计不及格人数:\n")
reno
=
0
avr
=
0
for(i
=
0
i
<
n
i++)
{
if(
score[i]
<
60)
{
reno++
printf("%d,
%s\n",
i+1,
name[i])
}
avr
+=
score[i]
}
printf("不及格人数为%d\n\n",
reno)
printf("统计成绩在平均分及平均分之上的学生人数:\n")
avr
/=
nreno
=
0
for(i
=
0
i
<
n
i++)
{
if(score[i]
>=
avr)
{
reno++
printf("%d,
%s\n",
i+1,
name[i])
}
}
printf("成绩在平均分及平均分之上的学生人数为%d\n\n",
reno)
printf("统计各分数段的人数及所占百分比(分数段为<60,60~79,>=80):\n")
a
=
b
=
c
=0
for(i
=
0
i
<
n
i++)
{
if(score[i]
<
60)
a++
else
if(score[i]
>=
80)
c++
else
b++
}
printf("<60:\t%.1f%%\n60~79:\t%.1f%%\n>=80:\t%.1f%%\n",100*a/n,100*b/n,100*c/n)
}
int chengji[100],t2char xingming[100][8],t1[8]
int i,j,n
printf("输入学生个数:\n')
scanf("%d",&n)
for(i=0i<ni++)
{
printf("输入第%d个学生姓名:",i+1)
scanf("%s",&xingming[i])
printf("成绩:")
scanf("%d"&chengji[i])
}
for(i=0i<ni++)
for(j=i+1j<nj++)
{
if(chengji[i]<chengji[j])
{
t2=chengji[i]
chengji[i]=chengji[j]
chengji[j]=t2
strcpy(t1, xingming[i])
strcpy(xingming[i], xingming[j])
strcpy(xingming[j], t1)
}
}
j=n*8/10
for(i=0i<ni++)
{
printf("序号 姓名 成绩 是否通过\n")
printf("%d %c %d",i+1,xingming[i],chengji[i])
if(i<=j)
printf("pass\n")
else
printf("fail\n")
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)