mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-13 12:20:57 +00:00
Format the C code in Clang-Format Style: Microsoft
This commit is contained in:
@@ -19,7 +19,7 @@ int linearSearchArray(int *nums, int len, int target) {
|
||||
}
|
||||
|
||||
/* 线性查找(链表) */
|
||||
ListNode* linearSearchLinkedList(ListNode* head, int target) {
|
||||
ListNode *linearSearchLinkedList(ListNode *head, int target) {
|
||||
// 遍历链表
|
||||
while (head != NULL) {
|
||||
// 找到目标节点,返回之
|
||||
@@ -36,14 +36,14 @@ int main() {
|
||||
int target = 3;
|
||||
|
||||
/* 在数组中执行线性查找 */
|
||||
int nums[10] = { 1, 5, 3, 2, 4, 7, 5, 9, 10, 8 };
|
||||
int nums[10] = {1, 5, 3, 2, 4, 7, 5, 9, 10, 8};
|
||||
int index = linearSearchArray(nums, 10, target);
|
||||
printf("目标元素 3 的索引 = %d\n", index);
|
||||
|
||||
/* 在链表中执行线性查找 */
|
||||
ListNode* head = arrToLinkedList(nums, 10);
|
||||
ListNode* node = linearSearchLinkedList(head, target);
|
||||
if(node == NULL) {
|
||||
ListNode *head = arrToLinkedList(nums, 10);
|
||||
ListNode *node = linearSearchLinkedList(head, target);
|
||||
if (node == NULL) {
|
||||
printf("目标节点值 3 的对应节点对象为 NULL\n");
|
||||
} else {
|
||||
printf("目标节点值 3 的对应节点对象为 addr: %p val: %d\n", node, node->val);
|
||||
|
||||
Reference in New Issue
Block a user