摘要: int *p1[5]; int (*p2)[5]; 首先,对于语句“int*p1[5]”,因为“[]”的优先级要比“*”要高,所以 p1 先与“[]”结合,构成一个数组的定义,数组名为 p1,而“int*”修饰的是数组的内容,即数组的每个元素。也就是说,该数组包含 5 个指向 int 类型数据的指针 阅读全文
posted @ 2022-02-07 20:27 晓风霜度- 阅读(102) 评论(0) 推荐(0)
摘要: while(x) { number++; x=x&(x-1); } 阅读全文
posted @ 2022-01-26 14:36 晓风霜度- 阅读(42) 评论(0) 推荐(0)
摘要: 一、int 类型转换为 string 类型 string s=to_string(asum+bsum);//int 转化为 string string/char 转换为 int 类型 1、首先将 字符串string 转为 C语言中的 const char* 类型(使用 _c.str()函数) 2、将 阅读全文
posted @ 2022-01-19 15:18 晓风霜度- 阅读(232) 评论(0) 推荐(0)
摘要: class Solution { public: ListNode* reverseList(ListNode* head) { ListNode *p; for(p=NULL; head; swap(head,p)) swap(p,head->next); return p; } }; 阅读全文
posted @ 2022-01-17 14:14 晓风霜度- 阅读(33) 评论(0) 推荐(0)
摘要: class Solution { public: bool hasCycle(ListNode *head) { ListNode* fast=head,* slow=head; while(fast&&fast->next) { fast=fast->next->next; slow=slow-> 阅读全文
posted @ 2022-01-16 11:53 晓风霜度- 阅读(59) 评论(0) 推荐(0)
摘要: 题目:给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。 不需要额外空间的方法,就往位运算上想,这里使用异或。 0与任何数字异或都是其本身,而相同的数字异或结果为0。 int singleNumber(vector<int>& nums) { in 阅读全文
posted @ 2022-01-15 18:35 晓风霜度- 阅读(49) 评论(0) 推荐(0)
摘要: #include <stdio.h> #define BUFSIZE 50 int main() { FILE* f; char buf[BUFSIZE] = "this is fputs function!\n hello fputs!"; f=fopen("D:\\1.txt","w"); if 阅读全文
posted @ 2022-01-14 10:21 晓风霜度- 阅读(233) 评论(0) 推荐(0)
摘要: #include <stdio.h> int main() { FILE* fp; char buf[20]; //打开文件 fp = fopen("D:\\1.txt", "r"); //判断是否成功 if (fp == NULL) { printf("打开文件失败"); } //获取文件 whi 阅读全文
posted @ 2022-01-14 09:58 晓风霜度- 阅读(97) 评论(0) 推荐(0)
摘要: int removeElement(vector<int>& nums, int val) { int k=0; for(int i=0;i<nums.size();i++) { if(nums[i]!=val) { nums[k++]=nums[i]; } } return k; 阅读全文
posted @ 2022-01-13 11:56 晓风霜度- 阅读(35) 评论(0) 推荐(0)
摘要: int j=0; for(int i=1;i<nums.size();i++) { if(nums[j]!=nums[i]) { nums[++j]=nums[i]; } } 阅读全文
posted @ 2022-01-13 10:52 晓风霜度- 阅读(67) 评论(0) 推荐(0)