日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言知道算法写不出代码,这个代码怎么写算法啊,求教,我真的不会写算法怎么办#incl...

發布時間:2023/11/27 编程问答 52 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言知道算法写不出代码,这个代码怎么写算法啊,求教,我真的不会写算法怎么办#incl... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

該樓層疑似違規已被系統折疊?隱藏此樓查看此樓

這個代碼怎么寫算法啊,求教,我真的不會寫算法怎么辦

#include "stdio.h"

#define N 3 //學生數3。

struct Student //建立結構體。

{

int num;

char name[20];

float score[3];

float aver;

};

int main()

{

void input (struct Student stu[]);

struct Student max(struct Student stu[]);

void print(struct Student stu);

struct Student stu[N],*p=stu; //定義結構體數組和指針。

input(p);

print(max(p)); //調用print函數,以max函數的返回值作為實參。

return 0;

}

void input(struct Student stu[])

{

int i;

printf("輸入各學生信息:學號、姓名、三門課成績:\n ");

for(i=0;i

{

scanf("%d %s %f %f %f",&stu[i].num,stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);

stu[i].aver=(stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3.0;

}

}

struct Student max(struct Student stu[])

{

int i,m=0;

for(i=0;i

if(stu[i].aver>stu[m].aver) m=i; //找出平均成績最高的學生在數組中的序號。

return stu[m]; //返回包含該生信息的結構元素。

}

void print(struct Student stu)

{

printf("\n成績最高的學生是:\n");

printf("學號:%d\n 姓名:%s\n 三門課成績:%5.1f,%5.1f,%5.1f\n 平均成績:%6.2f\n",stu.num,stu.name,stu.score[0],stu.score[1],stu.score[2],stu.aver);

}

總結

以上是生活随笔為你收集整理的c语言知道算法写不出代码,这个代码怎么写算法啊,求教,我真的不会写算法怎么办#incl...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

歡迎分享!

轉載請說明來源于"生活随笔",并保留原作者的名字。

本文地址:c语言知道算法写不出代码,这个代码怎么写算法啊,求教,我真的