字串比較 鍊錶實現

2021-04-06 14:39:27 字數 598 閱讀 2100

用鍊錶實現兩個字串的比較,相同則提示the same 並把他們列印出來(只用列印乙個就行了);不同提示not the same,然後把兩個不同的字串分別列印出來。

源**如下: vc6.0編譯通過

#include

#include

struct string;

int string_cmp(struct string *string1, struct string *string2)

else

return 0;

}return 1;

}struct string *string_write()

tail->next = str;

tail       = str;

tail->next = null;

scanf("%c",&ch);

}return head;

}void string_print(struct string *str)

printf("%c/n",temp->ch);

}int main()

else

return 0;

}

字串鍊錶設計

標頭檔案 ifndef link h define link h typedef struct stringnode stringnode 1.向鍊錶尾部插入乙個元素 int tailinsertnode stringnode pnode,char ptaildata 2.遍歷 void print...

比較字串

其實這是在 c 從入門到精通 上摘抄的,由於不知道漢字怎麼排序,就查了查書,寫在這裡也可以幫助其他初學者更方便的找到漢字的排序方法。用於排序 int compare string str1,string str2 int compare string str1,string str2,bool ig...

字串比較

題目是這樣的 比較兩個字串,忽略大小寫,比較長度不超過n,比較順序為字典序。返回如下 0 s1 s2 0 s1 s2 0 s1 首先我們會先寫乙個函式名,我想大部分同學會寫成如下形式 int strncompare char s1,char s2,int n 是的,我開始也是這樣寫的。可是我突然覺得...