当前位置:网站首页>C语言小笔记+题
C语言小笔记+题
2022-08-04 20:05:00 【冷瑾瑜】
1 unsigned int -255-----1 -1-----255
char 越界需要仔细考虑。%d 有符号打印整数 %u 无符号打印整数
.
输出结果:255
解释:strlen遇到'\0'停止,a[i]遍历循环的时候先从-1.--------------- -128,根据圆圈循环下一个数值是127----------1-----0('\0')(255+1=0 对于unsigned char)
所以数组a的长度是-128-+127 = 255
2.
3.寻找自幂数(153 (n= 3)1^3 + 5^3 + 3^3)
4.
5.
6.实现memcpy和strcpy
void* memcpy(void *dst, const void *src, size_t count)
{
//安全检查
assert( (dst != NULL) && (src != NULL) );
unsigned char *pdst = (unsigned char *)dst;
const unsigned char *psrc = (const unsigned char *)src;
//防止内存重复
assert(!(psrc<=pdst && pdst<psrc+count));
assert(!(pdst<=psrc && psrc<pdst+count));
while(count--)
{
*pdst = *psrc;
pdst++;
psrc++;
}
return dst;
}
char *my_strcpy(char *dst,const char *src)
{
assert(dst != NULL);
assert(src != NULL);
char *ret = dst;
memcpy(dst,src,strlen(src)+1);//把src中的'\0'也复制过去,strlen 只计算了字符串长度
return ret;
}
7.补码存储
8.大端小端
9.strlen与char
10.杨辉三角
11.推理面试
12.36匹马
13.烧香问题
14.
15.指针(free释放后指针的值不会改变)
16.sizeof与strlen问题
sizeof(&a) sizeof(*(&a)) sizeof(&a+1) sizeof(&a[0]+1)
strlen(arr) strlen(*arr) strlen(arr[1])
17.暴力求解法、三步反转法
18.时间复杂度o(n)就是n个元素全部遍历一次
杨氏矩阵:
将要对比的元素和最右上角元素对比
19.返回型参数--形参是实参的拷贝,不会影响实参
边栏推荐
- How to manually download and install SAP Fiori tools - Extension Pack for Visual Studio Code
- web 应用开发最佳实践之一:避免大型、复杂的布局和布局抖动
- 带你了解数据分布式存储原理
- Go study notes (Part 1) Configuring the Go development environment
- Initialization process of SAP UI5
- C语言基础[通俗易懂]
- Chrome安装zotero connector 插件
- How to promote the implementation of rural revitalization
- Finished product upgrade program
- SAP UI5 的初始化过程
猜你喜欢
随机推荐
Force KouTi (5), the longest text string back
面试官:索引为什么会失效?
基于HDF的LED驱动程序开发(2)
really time ntp service start command
If it is test axi dma catch a few words here
jMeter Thread group 对应的 constant timer
图片延迟加载、预加载
取证程序分类
成品升级程序
Tear down the underlying mechanism of the five JOINs of SparkSQL
LED的C语言应用程序
How to monitor code cyclomatic complexity by refactoring indicators
vehemently condemn
长时间序列遥感数据处理及在全球变化、物候提取、植被变绿与固碳分析、生物量估算与趋势分析等领域中的应用
多商户商城系统功能拆解22讲-平台端分销商品
KubeSphere简介,功能介绍,优势,架构说明及应用场景
nr部分计算
基于Nodejs的电商管理平台的设计和实现
Unreal 本地化 国家化 多语言
带你了解数据分布式存储原理