C语言6F多少,求助!!请人帮忙画C语言程序流程图.紧急!!!
#include <stdio.h>
#define N 10
struct student //第一步, 根據具體情況定義結構體類型。
{ double num; /*學號*/
float score[5]; //數組依次存放英語,數學,計算機基礎及平均分
};
void input( struct student arr[ ], int ) ; /*函數原型*/
void aver ( struct student arr[ ], int );
void order( struct student arr[ ], int );
void output( struct student arr[ ], int ) ;
void main( )
{ struct student stu[100]; /* 定義結構體數組*/
printf("水利水電學院07級5班 宋戈 學號200731580148");
input( stu, N ) ; /*依次調用自定義函數*/
aver( stu, N ) ; order( stu, N ) ; output( stu, N ) ;
}
void input( struct student arr[ ], int n )
{ int i, j ;
printf("\nInput 學號,數學,英語,計算機基礎\n");
for ( i=0 ; i<n; i++) //n名學生
{ scanf("%lf ", &arr[i].num);
for ( j=0 ; j<3 ; j++ )
scanf("%f", &arr[i].score[j]) ; /*輸入三科成績*/
}
}
void aver( struct student arr[], int n )
{ int i, j ;
for( i=0 ; i<n ; i++ ) //n名學生
{ arr[i].score[4]=0 ;
for ( j=0 ; j<3 ; j++ )
arr[i].score[4]+= arr[i].score[j];//求和
arr[i].score[3]=arr[i].score[4];
arr[i].score[4]=arr[i].score[4]/3 ; }
}
void order( struct student arr[ ], int n )
{ struct student temp ; int i, j ;
for( i=1 ; i<n ; i++ )
for( j=0 ; j<n-i ; j++ )
if ( arr[j].score[3]<arr[j+1].score[3] )
{ temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp ;}
}
void output( struct student arr[ ], int n )
{ int i, j ;
printf("* * * * * * * * * * * * * * * * * * * * * *\n");
printf("學號\t數學\t英語\t計算機\t總分\t平均\n") ;
for (i=0 ; i<n ; i++)
{ printf("%.0f\t", arr[i].num ) ;
for( j=0; j<5 ; j++ ) //輸出三科成績及平均成績
printf("%.2f\t", arr[i].score[j] ) ;
printf("\n") ; }
}
總結
以上是生活随笔為你收集整理的C语言6F多少,求助!!请人帮忙画C语言程序流程图.紧急!!!的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VC/MFC如何设置对话框背景颜色
- 下一篇: 如何完美的将对话框设置成无边框无标题栏样