构建一个简单的链表

 

#include <iostream>
#define NULL 0
using namespace std;
 
struct Student
{
       long num;
       float score;
       struct Student *next;
};
int main()
{
       Student a,b,c,*head,*p;
       a.num=30001;a.score=98;
       b.num=30002;b.score=95;
       c.num=30003;c.score=100;
 
       head=&a;
       a.next=&b;
       b.next=&c;
       c.next=NULL;
 
       p=head;
       do
       {
              cout<<p->num<<" "<<p->score<<endl;
              p=p->next;
       }while(p!=NULL);
 
       return 0;
}

你可能感兴趣的:(C++,链表,职场,休闲,链表构建)