You will first create an interface for handling string items. Basically, you will need to do the following:
Create an interface named item.h Define a type Item represents a char * (i.e., a c-string) Implement a less function that compares between two strings and return which
one should precede. Then, you will add to the linked list interface the following functions: linkedlistScanInit: The header of the function will be linkedlistScaninit(pLinkedList list). The function takes a linkedlist as input, reads from the command line a set of strings, and store them inside the linkedlist. You can call the function linkedlistAddNode to add a node to the end of the linked list. linkedlistShow: The header of the function will be linkedlistShow(pLinkedList list). The function takes a linkedlist as input, loops through the linkedlist and show what inside it
Finally, you will create a main, your main will be as follow:
}
You will use the code in linkedListSt.h and linkedListSt.c
抱歉,它来自 pdf,看起来很乱,我似乎无法在不弄乱它的情况下对其进行调整。
因此,我被要求在链接列表上使用选择排序方法对字符串进行基本排序。我这里的问题不是任何特定于代码的问题,而是“比较两个字符串的较少函数”是什么意思。这是否意味着它只需要声明?那会返回一个字符串指针还是一个字符串指针?另外,我无法理解 linkedlistScanInit 的含义?
我不完全确定这里的问题是什么。它没有要求我对实际列表进行排序,或者至少这是我对它的理解很差。
最佳答案
我猜它们的意思是一个函数,用于比较两个字符串中哪个字符串按字母顺序“小于”另一个字符串。
函数声明可能如下所示:
int lessThan(char *a, char *b);
如果 a 小于 b,则返回 1,否则返回 0。我将把实现留给您。
祝你好运
关于有人可以解释一下程序的这个提示吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41012221/