首页 > 代码库 > 单链表复习

单链表复习

// linklist.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <string>#include <iostream>using namespace std;struct student{    long number;    char name[10];    float score;    struct student *next;};int main(int argc, char* argv[]){    struct student a,b,c,*head,*p;    a.number=110801; strcpy(a.name,"小明");  a.score=98;    b.number=110802; strcpy(b.name,"小华");b.score=100;    c.number=110803; strcpy(c.name,"张三");c.score=95;    head=&a;    a.next=&b;    b.next=&c;    c.next=NULL;    p=head;    do     {        cout<<p->number<<"  "<<p->name<<"  "<<p->score<<endl;        p=p->next;    } while (p!=NULL);        return 0;}

 

单链表复习