小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

c語言結(jié)構(gòu)體和共用體1.有5個(gè)學(xué)生,每個(gè)學(xué)生的數(shù)據(jù)包括學(xué)號(hào)、姓名、3門課的成績(jī),從鍵盤輸入5個(gè)學(xué)生數(shù)據(jù)

 lixinhecom 2017-07-17
#include<stdio.h>
#define max 5 /*設(shè)定要輸入成績(jī)的學(xué)生個(gè)數(shù)*/

double zpj; /*總平均值*/
struct student /*結(jié)構(gòu)體*/
{
int num;
char name[10];
int score1;
int score2;
int score3;
double pj;
};
struct student stu[max],temp;

void Input() /*輸入函數(shù)*/
{ int i;
for(i=0;i<max;i++)
{printf("enter number"); scanf("%d",&stu[i].num); printf("enter name"); scanf("%s",&stu[i].name); printf("enter score1"); scanf("%d",&stu[i].score1); printf("enter score2"); scanf("%d",&stu[i].score2); printf("enter score3"); scanf("%d",&stu[i].score3); }
}

average() /*求平均值函數(shù)*/

{int i; for(i=0;i<5;i++) {stu[i].pj=stu[i].score1+stu[i].score1+stu[i].score3; zpj+=stu[i].pj; }
for(i=0;i<5;i++)
stu[i].pj/=3;
zpj/=max;
}

MAX() /*找出最高平均值的學(xué)生的函數(shù)*/
{int i,j; temp=stu[0]; for(i=0;i<max-1;i++) for(j=i+1;j<max;j++) if(stu[i].pj<stu[j].pj) temp=stu[j]; }





output() /*輸出函數(shù)*/

{int i; for(i=0;i<max;i++) printf("num=%d\n name=%s\n score1=%d\n score2=%d\n score3=%d\n aver=%f\n", stu[i].num,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].pj); printf("總平均分=%f\n\n",zpj); printf("平均分最高的學(xué)生\nnum=%d\n name=%s\n score1=%d\n score2=%d\n score3=%d\n aver=%f\n", temp.num,temp.name,temp.score1,temp.score2,temp.score3,temp.pj); }
void main() /*主函數(shù)*/
{

Input();
average();
MAX();
output();
}



自己寫的 符合你的要求
不足之處還請(qǐng)指教

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多