2024年1月8日
摘要: 从二分法开始,我都摘录了力扣和代码随想录的解法,CV的时候发现有“非商业用途请标注出处”,但是我自私了一下,觉得不美观,我写这个博客的初衷是总结给自己看的,所以接下来我复制下来都不会表明出处的哦,如果涉及到您的利益请联系我及时止损!谢谢! 阅读全文
posted @ 2024-01-08 20:13 lulixiu 阅读(2) 评论(0) 推荐(0) 编辑
  2024年1月7日
摘要: 长度最小的子数组 暴力解法 int minSubArrayLen(int target, int* nums, int numsSize){ //初始化最小长度为INT_MAX int minLength = INT_MAX; int sum; int left, right; for(left = 阅读全文
posted @ 2024-01-07 21:21 lulixiu 阅读(8) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> #include <stdlib.h> /* // 双向链表节点结构体 typedef struct ListNode { int val; // 节点值 struct ListNode* next; // 指向后继节点的指针 struct ListNode* 阅读全文
posted @ 2024-01-07 17:19 lulixiu 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 移除元素 第一种:暴力双循环 #include <stdio.h> int removeElement(int* nums, int size, int val) { int newSize = size; for (int i = 0; i < newSize; i++) { if (nums[i 阅读全文
posted @ 2024-01-07 17:19 lulixiu 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 本周练习内容 题目来自于力扣(掌握二分法) 题目链接 https://leetcode.cn/problems/binary-search/ 代码如下 #include <stdio.h> int search(int* nums, int numsSize, int target) { int l 阅读全文
posted @ 2024-01-07 17:19 lulixiu 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 列表是一种支持增删查改的元素有序集合,通常基于动态数组实现,其保留了数组的优势,同时可以灵 活调整长度。 列表的出现大幅地提高了数组的实用性,但可能导致部分内存空间浪费。 /* 列表类简易实现 */ typedef struct { int* arr; // 数组(存储列表元素) int capac 阅读全文
posted @ 2024-01-07 17:19 lulixiu 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 有序数组的平方 第一种,先平方后排序 #include <stdio.h> #include <stdlib.h> // 比较函数,用于快速排序 int compare(const void* a, const void* b) { int A = *((int*)a); int B = *((in 阅读全文
posted @ 2024-01-07 17:19 lulixiu 阅读(2) 评论(0) 推荐(0) 编辑
  2024年1月3日
摘要: 学会了一个 int main(int argc,char*argv []) 第一个是数量,第二个存值,跟命令行有关,见C PRIMER PLUS 312页 阅读全文
posted @ 2024-01-03 20:34 lulixiu 阅读(3) 评论(0) 推荐(0) 编辑
  2023年12月23日
摘要: 2023/11/4 简单看完翁恺C语言入门后的一些难点 经典的素数打印,以及观察改良后的代码,还有构造素数表 二进制的补码很关键,理解了它就能理解字节的知识 8个字节的二进制数的范围,加了unsigned就非负且乘二了,还加了有形象的图说明超过那个范围就会回环往复,inf表示无穷,nan表示不存在 阅读全文
posted @ 2023-12-23 19:37 lulixiu 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 1.插入排序 #include"stdio.h" #define N 5 int main() { //1 2 3 4 5 //2 1 3 4 5 int a[N]={1,2,3,4,5},i,j,tmp; for(i=1;i<N;i++) { j=i-1; tmp=a[i]; while(a[j] 阅读全文
posted @ 2023-12-23 19:35 lulixiu 阅读(2) 评论(0) 推荐(0) 编辑