摘要: assert函数介绍 assert宏的原型定义在<assert.h>中,其作用是如果它的条件返回错误,则终止程序执行,原型定义: #include <assert.h> void assert( int expression ); assert的作用是现计算表达式 expression ,如果其值为 阅读全文
posted @ 2020-11-28 22:56 txzing 阅读(559) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<malloc.h>typedef char ElemType;typedef struct LNode{ ElemType data; // struct LNode *next; //指针占4个字节 }LinkNode; //声明单链表节点类型 阅读全文
posted @ 2020-11-27 18:32 txzing 阅读(388) 评论(0) 推荐(0) 编辑
摘要: 进行迭代 //将一个数n分解为若干个从小到大排列的质数的积 //求质数因子 #include <iostream>using namespace std;int main(){ int n; cin >> n; if(n<2)return 0; //1没有质数 for(int i = 2;i*i<= 阅读全文
posted @ 2020-11-27 13:40 txzing 阅读(144) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include "math.h" void polyfit(int n, double *x, double *y, int poly_n, double p[]);void gauss_solve(int n,double 阅读全文
posted @ 2020-11-12 16:53 txzing 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 从别人那里COPY过来的,不是原创。 1.什么是大端,什么是小端? 大端:数据的高位字节存放在低地址内,数据的低位字节存放在高地址内。 小端:数据的高位字节存放在高地址内,数据的低位字节存放在低地址内。(低低,高高) 一个整型是4个字节,如:0x1a2b3c4d。电脑读取内存数据时,是从低位地址到高 阅读全文
posted @ 2020-11-11 15:56 txzing 阅读(1726) 评论(0) 推荐(0) 编辑
摘要: /*寻找数组内两个数的最小距离。比如: int a[] = {1,2,3,4,5,3,2,4,7,8,9,6,4,4,3}; n1 = 4, n2 = 8, 则,这两个数在数组a中的最小距离是2。 变成求解!*/ #include<stdio.h> int getDistance(int a[],i 阅读全文
posted @ 2020-11-11 15:38 txzing 阅读(366) 评论(0) 推荐(0) 编辑
摘要: 编写代码判断两棵二叉树是否为镜像二叉树镜像二叉树举例: a a b c ==> c bd d 下面是将一个树转化为镜像二叉树 void swap(struct BiTree** a, struct BiTree** b) //交换将左右子树交换{ struct BiTree* temp = NULL 阅读全文
posted @ 2020-11-11 11:44 txzing 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 借鉴了别人的代码,在经过自己的理解 /*设有n个人围成一圈 , 编号从1到n , 约定从编号为k(1 <= k <= n)的人从1开始报数 , 数到 m 的那个人被淘汰 , 接着下一个人重新从1开始报数 , 数到 m 再淘汰一人 , 如此反复 , 直至剩下最后一个人为止 我们可以知道约瑟夫问题是一个 阅读全文
posted @ 2020-11-06 09:41 txzing 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Intel、微软等公司曾经出过一道类似的面试题:#include <iostream.h>4#pragma pack(8)struct example1{short a;long b;};struct example2{char c;example1 struct1;short e;};#pragm 阅读全文
posted @ 2020-10-31 10:22 txzing 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 引用的本质其实就是const类型的指针(指针指向不能被改变),加上了const修饰的引用我觉得确实可以理解为 const type * const name,即指向的地址是不能改变的,地址所对应的值也是不能改变的。 常指针是指针的值不可改变,指向的内容可变。 第一种 等待完成操作,一定时间未完成跳出 阅读全文
posted @ 2020-10-31 10:04 txzing 阅读(100) 评论(0) 推荐(0) 编辑