[求助]程序为什么运行有错误,编译没错?
#include"stdafx.h"#include"iostream"
using namespace std;
int i;
struct student{long num;
char name[12];
float score[3],ave;
student *next,*o;};
student *o;
void maxm(float a[],int n){
float max=a[0];
for(int k=0;k<n;k++){
if(a[k]>max)max=a[k];}
cout<<max;
for(int l=0;l<n;l++){
if(a[l]=max)
cout<<"第"<<l<<"号学生的总成绩最高";}
}
void put(student*head){
long num;
int n=0;
student *New;
while(n<=4){cout<<"输入第"<<n+1<<"个学生的学号.";
cin>>num;
n++;
New=new student;
New->num=num;
cout<<"请输入学号为"<<num<<"的成绩"<<endl;
cin.ignore(1);
cout<<"输入姓名:";
cin.get(New->name,12);
cout<<"输入数学 语文 英语的成绩"<<endl;
for(int j=0;j<3;j++)
cin>>New->score[j];
if(head=NULL)
head=New;
else o->next=New;
o=New;}
o->next=NULL;
return;}
void avrage(student*head){
float total[5];
o=head;
if(head==NULL)
return;
while(i=0,i<=4,i++)
{o->ave=0;
for(int j=0;j<3;j++){
o->ave+=o->score[j];
o->ave=o->ave/3.0f;
total[i]=o->ave;
cout<<"学生"<<j<<"的总平均成绩为:"<<total[i];
o=o->next;}}
maxm(total,5);
return;}
void main(){student*stu=NULL;
put(stu);
avrage(stu);}