#include<iostream.h>
typedef struct node
{
int music[5];
char name[10];
int i;
struct node *next;
};
void set(node *p)
{
p=new node;
node m1={{1,2,3,4,5},"小蜜蜂",1,NULL};
node *s1=new node;
s1=&m1;
p->next=s1;
node m2={{5,4,3,2,1},"遇见",2,NULL};
node *s2=new node;
s2=&m2;
s1->next=s2;
}
int length(node *p)
{
int n=0;
node *q=p->next;
while(q!=NULL)
{
n++;
q=q->next;
}
return n;
}
void display(node *p)
{
int n=length(p),i;
node *q=p->next;
cout<<"歌曲库显示\n";
for(i=1;i<=n;i++)
{
cout<<i<<'.'<<q->name<<endl;
q=q->next;
}
}
void main()
{
node hebe;
set(&hebe);
display(&hebe);
}
打击帮忙看下..编译没有问题..运行老是说我非法.谢了.........