65,210
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include <string>
using namespace std;
typedef struct student
{
long stuNo;
float score;
string stuName;
struct student *next;
}linkList;
linkList *head,*p;
linkList *createList()
{
long _stuNo;
float _score;
string _stuName;
linkList *head,*r,*p;
head=new linkList;
p=head;
head->next=NULL;
r=p;
cout<<"StuNo=";
cin>>_stuNo;
cout<<"stuNmae=";
cin>>_stuName;
cout<<"score=";
cin>>_score;
while(_stuNo!=0)
{
p=new linkList;
p->stuNo=_stuNo;
p->stuName=_stuName;
p->score=_score;
p->next=NULL;
r->next=p;
r=r->next;
cout<<"StuNo=";
cin>>_stuNo;
cout<<"stuNmae=";
cin>>_stuName;
cout<<"score=";
cin>>_score;
}
return(head);
}
outPut(linkList *s)
{
linkList *p;
p=s->next;
while(p!=NULL)
{
cout<<"SutNo: "<<p->stuNo<<"\t";
cout<<"StuName: "<<p->stuName<<"\t";
cout<<"score: "<<p->score<<endl;
p=p->next;
}
cout<<"输出结束"<<endl;
}
void Del(linkList *head,long _stuNo)
{
linkList *q;
linkList *p;
p=head;
while(p->next!=NULL && p->next->stuNo!=_stuNo)
{
p=p->next;
}
if(p->next==NULL)
cout<<"该学号不存在"<<endl;
else
{
q=p->next;
p->next=q->next;
delete q;
}
}
void Insert(linkList *head,long stuNo,long _stuNo,string _stuName,float _score)
{
linkList *s,*q,*p;
s=new linkList;
s->stuNo=_stuNo;
s->stuName=_stuName;
s->score=_score;
q=head;
p=head->next;
while(p!=NULL && p->stuNo!=stuNo)
{
q=p;
p=p->next;
}
q->next=s;
s->next;
}
int main()
{
return 1;
}