- 博客(4)
- 收藏
- 关注
原创 二叉树先序创建,先序、中序、后序遍历递归算法和非递归算法
#include <stdio.h>#include <stdlib.h>#define MAX 100typedef struct tnode{ char data; struct tnode *lchild; struct tnode *rchild; }TNode, *TLink;typedef struct nod...
2019-08-01 20:18:33 521 1
原创 fgets() 字符串读取 Linux环境
由于gets()函数会导致段错误,超出数组下标造成越界,所以了解了以下函数fgets( 数组名, sizeof(数组名),流(一般键盘输入为stdin))fgets()函数的好处是防止了内存溢出,由于获取了数组长度,不会发生段错误fgets()读取字符串长度为读取数组长度n-1位,若数组空间足够大,回车键字符‘\n’也会被读取进数组,并且在最后一位补‘\0’表示字符串结束一般分以下两种情况...
2019-07-14 19:48:05 914
原创 getch()
本次测试在linux环境下#include <stdio.h>#include <curses.h> //头文件与Windows环境下不同int main(){ char ch; int i; initscr(); //初始化屏幕 noecho(); //无回显,想要有回显可以使用echo(); while((...
2019-07-14 19:00:05 375
原创 C语言 最大公约数与素数探求
本页求最大公约数用到的方法有三:1、 穷举法:先找到a,b中较小者赋值给t,从t-1开始求余,判断是否为公约数,往下穷举。int Gcd_1(int a, int b){ int i, min; min = a < b ? a : b; /*取最小值*/ while((a % min != 0 || b % min != 0) && (m...
2019-07-10 21:29:47 736
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人