急!这个C语言程序的流程图怎么画?
#include<stdio.h>#include<stdlib.h>#defineN1024typedefstructnode{intsno;/*这里分别是学号(便于最...
#include<stdio.h>
#include<stdlib.h>
#define N 1024
typedef struct node
{
int sno;/*这里分别是学号(便于最后列表时统计),四门课的分数,总分,平均分*/
int course1;
int course2;
int course3;
int course4;
int aver;
}student;
void main()
{
int i,j,number;
int total1,total2,total3,total4;
total1=total2=total3=total4=0;/*total指的是四门课程的平均分*/
student st[N],temp;
printf("Please input the student's number:");/*确定学生人数*/
scanf("%d",&number);
if(number>1024)
{
printf("The number is too large!\n");
exit(0);
}
for(i=0;i<number;i++)/*进行成绩输入*/
{
printf("Please input the %dth student's sno:",i+1);
scanf("%d",&st[i].sno);
printf("Please input the %d's student's course1:",st[i].sno);
scanf("%d",&st[i].course1);
printf("Please input the %d's student's course2:",st[i].sno);
scanf("%d",&st[i].course2);
printf("Please input the %d's student's course3:",st[i].sno);
scanf("%d",&st[i].course3);
printf("Please input the %d's student's course4:",st[i].sno);
scanf("%d",&st[i].course4);
st[i].aver=(st[i].course1+st[i].course2+st[i].course3+st[i].course4)/4;
}
for(i=0;i<number;i++)/*输出每个学生的平均分*/
printf("The %d's student's aver-score is:%d\n",st[i].sno,st[i].aver);
for(i=0;i<number;i++)/*输出每科目平均分*/
{
total1+=st[i].course1;
total2+=st[i].course2;
total3+=st[i].course3;
total4+=st[i].course4;
}
total1/=number;
total2/=number;
total3/=number;
total4/=number;
printf("The averscore of course1 is:%d\n",total1);
printf("The averscore of course2 is:%d\n",total2);
printf("The averscore of course3 is:%d\n",total3);
printf("The averscore of course4 is:%d\n",total4);
for(i=0;i<number-1;i++)/*进行冒泡排序*/
for(j=i+1;j<number;j++)
if(st[i].aver<st[j].aver)
{
temp=st[i];
st[i]=st[j];
st[j]=temp;
}
printf("The list of the student's course:\n");
printf("==========\n");/*列表公布成绩*/
for(i=0;i<number;i++)
{
printf("%d.",i+1);
printf("%dth student:%d\n",st[i].sno,st[i].aver);
}
谢谢了 展开
#include<stdlib.h>
#define N 1024
typedef struct node
{
int sno;/*这里分别是学号(便于最后列表时统计),四门课的分数,总分,平均分*/
int course1;
int course2;
int course3;
int course4;
int aver;
}student;
void main()
{
int i,j,number;
int total1,total2,total3,total4;
total1=total2=total3=total4=0;/*total指的是四门课程的平均分*/
student st[N],temp;
printf("Please input the student's number:");/*确定学生人数*/
scanf("%d",&number);
if(number>1024)
{
printf("The number is too large!\n");
exit(0);
}
for(i=0;i<number;i++)/*进行成绩输入*/
{
printf("Please input the %dth student's sno:",i+1);
scanf("%d",&st[i].sno);
printf("Please input the %d's student's course1:",st[i].sno);
scanf("%d",&st[i].course1);
printf("Please input the %d's student's course2:",st[i].sno);
scanf("%d",&st[i].course2);
printf("Please input the %d's student's course3:",st[i].sno);
scanf("%d",&st[i].course3);
printf("Please input the %d's student's course4:",st[i].sno);
scanf("%d",&st[i].course4);
st[i].aver=(st[i].course1+st[i].course2+st[i].course3+st[i].course4)/4;
}
for(i=0;i<number;i++)/*输出每个学生的平均分*/
printf("The %d's student's aver-score is:%d\n",st[i].sno,st[i].aver);
for(i=0;i<number;i++)/*输出每科目平均分*/
{
total1+=st[i].course1;
total2+=st[i].course2;
total3+=st[i].course3;
total4+=st[i].course4;
}
total1/=number;
total2/=number;
total3/=number;
total4/=number;
printf("The averscore of course1 is:%d\n",total1);
printf("The averscore of course2 is:%d\n",total2);
printf("The averscore of course3 is:%d\n",total3);
printf("The averscore of course4 is:%d\n",total4);
for(i=0;i<number-1;i++)/*进行冒泡排序*/
for(j=i+1;j<number;j++)
if(st[i].aver<st[j].aver)
{
temp=st[i];
st[i]=st[j];
st[j]=temp;
}
printf("The list of the student's course:\n");
printf("==========\n");/*列表公布成绩*/
for(i=0;i<number;i++)
{
printf("%d.",i+1);
printf("%dth student:%d\n",st[i].sno,st[i].aver);
}
谢谢了 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询