爱问知识人 爱问教育 医院库

加急!!!求救!!c语言,链表的操作!知道

首页

加急!!!求救!!c语言,链表的操作!知道


        

提交回答

全部答案

    2018-04-04 06:23:46
  •   123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312#define N 20typedef struct LNode{    char num[N];    char name[N];    int age;    float Score;    LNode *next;}LNode;class LinkList{private:    LNode *head;    int length;public:    LinkList();    bool IsCreate();    void ListSize();    void CreatList();    void InsertList();    void DeleteList();    void Find();    void Display();    void BubbleSortList();     void Count();};-------------------#include "ds。
      h"#include #include string。h>#include stdlib。h>#include conio。h>using namespace std;  LinkList::LinkList(){    head=(LNode *)malloc(sizeof(LNode));    head->next=NULL;    length=0;}bool LinkList::IsCreate(){    if(length==0)        return 0;    return 1;}void LinkList::ListSize(){    if(!IsCreate())    {        cout>n;        LNode *p=head;length=n;        for(int i=n;i>0;i--)        {            LNode *p=(LNode *)malloc(sizeof(LNode));            cout>p->num;            cout>p->name;            cout>p->age;            cout>p->Score;            coutnext=head->next;            head->next=p;        }        cout>num;        LNode *p=head->next;        while(p&&strcmp(p->num,num)!=0)        {            p=p->next;        }        if(!p)cout>num;        LNode *p=head;        while(p->next&&strcmp(p->next->num,num)!=0)        {            p=p->next;        }        if(!(p->next))coutnext;            p->next=p->next->next;            free(q);        }        coutnext;        while(p)        {            coutnext;        }        cout>n;        if(nlength 1)coutnext;                i ;                }            cout>q->num;            cout>q->name;            cout>q->age;            cout>q->Score;            q->next=p->next;            p->next=q;            length ;            coutnext;        LNode *_node=head->next;        char temp1[N],temp2[N];int temp3;float temp4;        for(;_temp->next;_temp=_temp->next)        {            for(_node=head->next;_node->next;_node=_node->next)            {                if(_node->Scorenext->Score)                {                    strcpy(temp1,_node->num);                    strcpy(_node->num,_node->next->num);                    strcpy(_node->next->num,temp1);                    strcpy(temp2,_node->name);                    strcpy(_node->name,_node->next->name);                    strcpy(_node->next->name,temp2);                    temp3=_node->age;                    _node->age=_node->next->age;                    _node->next->age=temp3;                    temp4=_node->Score;                    _node->Score=_node->next->Score;                    _node->next->Score=temp4;                 }            }        }    }}void LinkList::Count(){    if(!IsCreate())    {        coutnext;int count=0;        while(p)        {            if(p->Scorenext;        }        cout>order;            switch(order)            {                case 1:    L。
      CreatList();break;                case 2:    L。Display();;break;                case 3:    L。InsertList();break;                case 4:    L。
      DeleteList();;break;                case 5:    L。Find();break;                case 6:    L。ListSize();break;                case 7:    L。
      BubbleSortList();break;                case 8: L。Count();break;                case 9:    flag=0;break;            }            cout>a;        if(!strcmp(a,"Y")||!strcmp(a,"y"))        {            cout
    vc6可以运行
    ds。
      h就是前半部分
    #include
    改成:
    #include
    using namespace std;
    加外, 在而且工具==〉编译环境==〉目录==〉包含文件 -->C
    中要有这一句:
    C:Dev-Cpp_gcc321Dev-Cppincludec mingw32
    C:Dev-Cpp_gcc321Dev-Cpp是我的DEV安装目录
    根据你的安装目录做适当修改:。
      

    桂***

    2018-04-04 06:23:46

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 175-194
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):