有人可以解释一下程序的这个提示吗?

标签 c sorting

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/

相关文章:

c - 我如何告诉我的 IDE 以特定方式编译我的 CMake 项目?

java - 对堆排序的直观理解?

c# - 如何对 KeyedCollection<TKey, TItem> 进行排序?

c - 冗余线程的分歧语句

c - 字符串数组上的 shmget 和 shmat

c++ - C++ 中的归并排序

python - 按 MultiIndex 的一级对 pandas DataFrame 进行排序

database - 还使用 where 子句时如何排序

c - 指定初始化器 : GCC warning message: near initialization and other warning messages

C 将字符命令行参数转换为整数数组