简单链表
1 #define NULL 0 2 #include <iostream> 3 4 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 5 using namespace std; 6 struct Student 7 { 8 long num; 9 float score; 10 struct Student *next; 11 }; 12 13 int main(int argc, char** argv) { 14 Student a,b,c,*head,*p; 15 a.num=31001; 16 a.score=99; 17 b.num=31002; 18 b.score=78; 19 c.num=31009; 20 c.score=87; 21 22 head=&a; 23 a.next=&b; 24 b.next=&c; 25 c.next=NULL; 26 p=head; 27 28 do 29 { 30 cout<<p->num<<" "<<p->score<<endl; 31 p=p->next; 32 }while(p!=NULL); 33 return 0; 34 }