随笔分类 -  C语言教程

摘要:力扣(LeetCode)官网 - 全球极客挚爱的技术成长平台 /** * Note: The returned array must be malloced, assume caller calls free(). */ int cmp(const void * a, const void * b) 阅读全文
posted @ 2023-09-26 17:35 朵朵奇fa 阅读(14) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main () { char* s = "hello"; // 字符串名字就是首地址 printf("%x\n",s); // s是char指针,size = 4 or 8 printf("sizeof s is %d\n", sizeof(s)); / 阅读全文
posted @ 2023-09-26 17:01 朵朵奇fa 阅读(28) 评论(0) 推荐(0) 编辑
摘要:167. 两数之和 II - 输入有序数组 - 力扣(LeetCode) /** * Note: The returned array must be malloced, assume caller calls free(). */ int* twoSum(int* numbers, int num 阅读全文
posted @ 2023-09-26 14:50 朵朵奇fa 阅读(10) 评论(0) 推荐(0) 编辑
摘要:力扣(LeetCode)官网 - 全球极客挚爱的技术成长平台 /** * Note: The returned array must be malloced, assume caller calls free(). */ int* intersection(int* nums1, int nums1 阅读全文
posted @ 2023-09-25 16:23 朵朵奇fa 阅读(116) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include<stdio.h> int main() { int nums[] = { 1,1,2,2,3,4,5,6,6 }; int size = sizeof(nums) / sizeof(nums[0]); // 创建一个全0的空数组 int* c 阅读全文
posted @ 2023-09-25 14:48 朵朵奇fa 阅读(630) 评论(0) 推荐(0) 编辑
摘要:26. 删除有序数组中的重复项 - 力扣(LeetCode) int checkIn(int* nums, int numsSize, int target) { for (int i = 0; i < numsSize; i++) { if (nums[i] == target) { return 阅读全文
posted @ 2023-09-25 10:52 朵朵奇fa 阅读(23) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include<stdio.h> int* removeDuplicates(int numsSize) { // malloc是常用的动态内存分配 int* arr = (int*)malloc(numsSize * sizeof(int)); retur 阅读全文
posted @ 2023-09-25 09:36 朵朵奇fa 阅读(9) 评论(0) 推荐(0) 编辑
摘要:27. 移除元素 - 力扣(LeetCode) int removeElement(int* nums, int numsSize, int val){ int left = 0; int right = 0; while (right < numsSize){ if (nums[right] != 阅读全文
posted @ 2023-09-22 17:29 朵朵奇fa 阅读(62) 评论(0) 推荐(0) 编辑
摘要:int search(int* nums, int numsSize, int target){ int left = 0; int right = numsSize - 1; int middle; while (left <= right){ middle = (left + right) / 阅读全文
posted @ 2023-09-22 17:18 朵朵奇fa 阅读(29) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include<stdio.h> void prinfArray(int* nums, int size) { for (int i=0; i<size; i++) { printf("%d ", nums[i]); } printf("\n"); } in 阅读全文
posted @ 2023-09-22 14:12 朵朵奇fa 阅读(7) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示