⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comp2list.txt

📁 It is an ebook about data structures,mainly linked list
💻 TXT
字号:
How to compare two linked lists? Write a C program to compare two linked lists. 

Discuss it!          

Here is a simple C program to accomplish the same. 


int compare_linked_lists(struct node *q, struct node *r) 
{ 
    static int flag; 
     
    if((q==NULL ) && (r==NULL)) 
    { 
         flag=1; 
    } 
    else 
    { 
        if(q==NULL || r==NULL) 
        { 
            flag=0; 
        } 
        if(q->data!=r->data) 
        { 
            flag=0; 
        } 
        else 
        { 
           compare_linked_lists(q->link,r->link); 
        } 
    } 
    return(flag); 
} 



Another way is to do it on similar lines as strcmp() compares two strings, character by character (here each node is like a character). 
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -