请教下大家这段程序的错误在哪里,怎么改都不对??
#include<iostream.h>#include<string.h>
#include<stdlib.h>
#include<string.h>
#include<iomanip.h>
struct node
{
char Name[9],Class_0[20],Num[11];
int Order;
float Elec,C_prog,Media,Eng,Math,Sport,Polity,Ave;
node *next;
};
void *Create_Order()
{
node *pn,*head=0;
int num;
cout<<"产生一条有序链表,请输入学生班级学号姓名与成绩,以-1结束"<<endl;
cin>>num;
while(num!=-1)
{
pn=new node;
pn->num=num;
cin>>pn->score; //???
head=Insert(head,pn); //??
cin>>num;
}
return head;
}
void *Satistic(node *head,char num[]) //计算平均分
{
while(head!=0)
{
p->Satistic=(p->Elec+p->C_prog+p->Media+p->Eng+p->Math+p->Sport+p->Polity)/7;
p=p->next;
}
}
void *Lookup(node *head,char num[]) //查找指定学生信息
{
cout<<"请输入要查询的学生学号,以-1结束"<<endl;
cin>>num;
node *pc,*pa;
pc=pa=head;
if(head==NULL)
{
cout<<"链表为空"<<endl; //链表为空
return NULL;
}
else
{
while(pc!=0&&pc->num!=num) //查找节点
{
pa=pc;
pc=pc->next;
}
if(pc==NULL)
cout<<"未找到该学生信息"<<endl;
else
{
cout<<"班级 学号 姓名 电子技术 C++程序设计 多媒体技术 大学英语 高等数学 大学体育 马克思主义政治经济学 平均成绩 名次"<<endl;
cout<<pc->Class_0<<pc->Num<<pc->Name<<pc->Elec<<pc->C_prog<<pc->Media<<pc->Eng<<pc->Math<<pc->Sport<<pc->Polity<<pc->Ave<<pc->Order;
}
}
}
void *Modify(node *head) //????修改指定学生信息
{
cout<<"请输入要修改的学生学号"<<endl;
cin>>num;
}
void *Delete(node *head,char num[]) //删除指定学生信息
{
cout<<"请输入要删除学生的学号"<<endl;
cin>>num;
node *pc,*pa;
pc=pa=head;
if(head==NULL)
{
cout<<"链表为空"<<eddl;
return NULL;
}
else if(pc->num==num)
{
head=pc->next;
delete pc;
cout<<"学生信息已删除"<<endl;
}
else
{
while(pc!=0&&pc->num!num)
{
pa=pc;
pc=pc->next;
}
if(pc==NULL)
cout<<"链表中没有要删除的学生信息"<<endl;
else
{
pa->next=pc->next;
delete pc;
cout<<"学生信息已删除"<<endl;
}
}
return head;
}
void sort(int s) //排序后输出
{
int chang;
int b[40];
while(s==0)
{
cout<<"没有记录,请先输入记录!"<<endl;
break;
}
if(s!=0)
{
cout<<"班级 学号 姓名 电子技术 C++程序设计 多媒体技术 大学英语 高等数学 大学体育 马克思主义政治经济学 平均成绩 名次"<<endl;
void *Insert(node *head,node *pn) //插入新学生信息
{
cout<<"请输入要插入的学生信息"<<endl;
//???
node *pc,*pa;
pc=pa=head;
if(head==0)
{
head=pn;
pn->next=0;
return head;
}
if(pn->score>=pc->score)
{
pn->next=head;
head=pn;
return head;
}
while(pc!=0&&pn->score<=pc->score)
{
pa=pc;
pc=pc->next;
}
pn->next=pc;
pa->next=pn;
return head;
}
void Output(node *head) // 输出函数
{
node *p=head;
cout<<"班级 学号 姓名 电子技术 C++程序设计 多媒体技术 大学英语 高等数学 大学体育 马克思主义政治经济学 平均成绩 名次"<<endl;
while(p!=0)
{
cout<<pc->Class_0<<pc->Num<<pc->Name<<pc->Elec<<pc->C_prog<<pc->Media<<pc->Eng<<pc->Math<<pc->Sport<<pc->Polity<<pc->Ave<<pc->Order;
p=p->next;
}
}
void Delchain(node *head) //删除整个表格
{
node *p;
p=head;
while(head)
{
head=p->next;
delete p;
p=head;
cout<<"表格已删除"<<endl;
}
}
void main()
{
node *head;
int num,x;
cout<<" ********菜单****** "<<endl;
cout<<" *输入学生信息请按 1* "<<endl;
cout<<" *计算平均分请按 2* "<<endl;
cout<<" *查询学生信息请按 3* "<<endl;
cout<<" *修改学生信息请按 4* "<<endl;
cout<<" *删除学生信息请按 5* "<<endl;
cout<<" *按平均分排序请按 6* "<<endl;
cout<<" *插入学生信息请按 7* "<<endl;
cout<<" *输出学生信息表请按8* "<<endl;
cout<<" *删除表格请按 9* <<endl;
cin>>x;
switch(x)
{
case 1:Create_order();
case 2:Satistic(head,num[]);
case 3:Lookup(head,num[]);
case 4:Modify(head);
case 5:Delete(head,num[])
case 6:Sort();
case 7:Insert();
case 8:Output(head);
case 9:Delchain;
}
}
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(22) : error C2039: 'num' : is not a member of 'node'
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(7) : see declaration of 'node'
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(23) : error C2039: 'score' : is not a member of 'node'
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(7) : see declaration of 'node'
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(24) : error C2065: 'Insert' : undeclared identifier
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(24) : error C2440: '=' : cannot convert from 'int' to 'struct node *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(33) : error C2065: 'p' : undeclared identifier
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(33) : error C2227: left of '->Satistic' must point to class/struct/union
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(33) : error C2227: left of '->Elec' must point to class/struct/union
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(33) : error C2227: left of '->C_prog' must point to class/struct/union
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(33) : error C2227: left of '->Media' must point to class/struct/union
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(33) : error C2227: left of '->Eng' must point to class/struct/union
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(33) : error C2227: left of '->Math' must point to class/struct/union
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(33) : error C2227: left of '->Sport' must point to class/struct/union
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(33) : error C2227: left of '->Polity' must point to class/struct/union
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(34) : error C2227: left of '->next' must point to class/struct/union
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(50) : error C2039: 'num' : is not a member of 'node'
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(7) : see declaration of 'node'
e:\microsoft visual studio\common\msdev98\bin\cpp1.cpp(50) : fatal error C1903: unable to recover from previous error(s); stopping compilation
执行 cl.exe 时出错.