[i] 做一個學生成績管理系統
學生成績有語文 數學 英語
功能: 錄入成績 找最三科總分的最高分 最低分 算出平均分
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
//定義一個學生的結構體
struct Student{
double yuwen;
double shuxue;
double yingyu;
struct Student *next;
};
struct Class{
struct Student *min;
struct Class *next;
};
//全域變數方便使用
double ymax =0;
double ymin =99;
double smax = 0;
double smin = 99;
double ywmax = 0;
double ywmin =99;
double sum1= 0;
double sum2= 0;
double sum3= 0;
struct Class *wen=NULL;
struct Class *hand=NULL;
struct Student *stuHead=NULL;//用來新建資訊的班級
struct Class *newData=https://bbs.csdn.net/topics/NULL;//用來新建資訊的班級
struct Student *chengjishuyu(int stunum)
{
int i;
int p;
int sum;
float avg;
struct Student *new2;
struct Student *new3;
struct Student *head;
printf("\n\n接下來請輸入每個班的學生的學科對應的成績\n");
for(p=1;p<=5;p++){
new2=(struct Student *)malloc(sizeof(struct Student));
new3=new2;
printf("輸入 %d 個班的第 %d 個學生的英語成績\n",stunum,p);
scanf("%lf",&(new2->yingyu));
if(new2->yingyu < 0 || new2->yingyu >100)
{
printf("你的成績輸入有誤,請重新輸入!\n");
scanf("%lf",&(new2->yingyu));
}
printf("輸入 %d 個班的第 %d 個學生的數學成績\n",stunum,p);
scanf("%lf",&(new2->shuxue));
if(new2->shuxue < 0 || new2->shuxue >100)
{
printf("你的成績輸入有誤,請重新輸入!\n");
scanf("%lf",&(new2->shuxue));
}
printf("輸入 %d 個班的第 %d 個學生的語文成績\n",stunum,p);
scanf("%lf",&(new2->yuwen));
if(new2->yuwen < 0 || new2->yuwen >100)
{
printf("你的成績輸入有誤,請重新輸入!\n");
scanf("%lf",&(new2->yuwen));
}
if(head == NULL){
new3= head;
head = new2;
new2 = new2->next ;
}else{
head->next = new2;
new2 = new2->next ;
}
sum1 +=new3->yuwen;//累加每個人的語文成績保存到全域變數
for(int j=1;j<=5;j++)//判斷每個輸入的語文成績的大小,并保存到全域變數
{
for(int i=1;i<=5;i++){
if(ywmax < new3->yuwen)
{
ywmax =new3->yuwen;
}else if(ywmin > new3->yuwen){
ywmin=new3->yuwen;
}
}
}
sum2 += new3->yingyu;//累加每個人的英語成績保存到全域變數
for(int j=1;j<=5;j++)//判斷每個輸入的英語成績的大小,并保存到全域變數
{
for(int i=1;i<=5;i++){
if(ymax < new3->yingyu)
{
ymax =new3->yingyu;
}else if(ymin > new3->yingyu){
ymin=new3->yingyu;
}
}
}
sum3 +=new3->shuxue;//累加每個人的數學成績保存到全域變數
for(int j=1;j<=5;j++)//判斷每個輸入的數學成績的大小,并保存到全域變數
{
for(int i=1;i<=5;i++){
if(smax < new3->shuxue)
{
smax =new3->shuxue;
}else if(smin > new3->shuxue){
smin=new3->shuxue;
}
}
}
}
for(int i=1;i<=5;i++){
printf("***",new3->shuxue);
}
return new3;
}
struct Class *banjixinxi(struct Class *head)
{
int j;
for(j=1;j<=5;j++)
{
stuHead = chengjishuyu(j);
}
return head;
}
int main()
{
struct Class *han;
struct Class *head;
double ypin;
double ywpin;
double spin;
while(1){
head=banjixinxi(head);
ywpin=sum1/25;
ypin=sum2/25;
spin=sum3/25;
printf("\n********************************************************************************\n");
printf("你要查找的英語最高分是 %lf ,最低分 %lf, 平均分 %lf\n",ymax,ymin,ypin);
printf("你要查找的語文最高分是 %lf ,最低分 %lf, 平均分 %lf\n",ywmax,ywmin,ywpin);
printf("你要查找的數學最高分是 %lf ,最低分 %lf, 平均[img=https://img-
printf("********************************************************************************\n");
}
return 0;
}
uj5u.com熱心網友回復:
有什么問題呢?還是單純的代碼展示?uj5u.com熱心網友回復:
樓主的代碼寫的不全呢,比如:struct Class *banjixinxi(struct Class *head)
{
int j;
for(j=1;j<=5;j++)
{
stuHead = chengjishuyu(j);
}
return head;
}
這里的head什么也沒做,直接回傳,所以程式里除了一些編譯錯誤,就是代碼還沒寫完,即使沒有這些錯誤也不能運行。建議樓主寫完了再問吧
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/20710.html
標籤:C語言
上一篇:使用mysql++報錯
下一篇:vs2012的sfml2.3.2提示:無法打開檔案“sfml-graphics.lib,sfml-window.lib,sfml-system.lib”求解
