
00-C标准库与数据结构代码
西红柿爆炒鸡蛋
成败论英雄
展开
-
07 --查找
顺序查找#include<stdio.h>#define N 10int seqsearch(int *a,int key);int main(int argc, const char *argv[]){ int a[]={12,2,3,5,2,8,7,6,9,11}; int i,key; char ch; i=seqsearch(a,4); if(i==-1) { printf("no find"); } else { printf("%d",a[i]原创 2020-11-26 17:41:03 · 180 阅读 · 0 评论 -
06 -- 二叉树
二叉树btree.h#ifndef __BTREE_H__#define __BTREE_H__#include <stdio.h>#include <stdlib.h>#include <stdbool.h>typedef char dataype_bt;/* 动画演示: [data] [lchild] [rchild]*/typedef struct btreenode{ //树节点 dataype_bt d原创 2020-11-26 15:38:46 · 143 阅读 · 0 评论 -
05 -- 队列
顺序队列seqqueue.h#ifndef __SEQQUEUE_H__#define __SEQQUEUE_H__#include <stdio.h>#include <stdlib.h>#include <stdbool.h>#define MAXSIZE 10typedef int datatype;typedef struct seqqueue{ datatype data[MAXSIZE]; //指针 --> 指向数组空间 in原创 2020-11-26 13:32:56 · 138 阅读 · 0 评论 -
04 -- 栈
顺序栈sqstack.h#ifndef __LINKLIST_H__#define __LINKLIST_H__#include <stdio.h>#include <stdlib.h>typedef int datatype;typedef struct node{ datatype *data; //int指针 int maxlen; //栈空间(堆,栈都是固定空间的,容易溢出) int top; //栈顶}sqstack;exter原创 2020-11-25 18:15:36 · 152 阅读 · 0 评论 -
03-双向循环链表
双向循环链表dlist.h#ifndef __DLIST_H__#define __DLIST_H__#include <stdio.h>#include <stdlib.h>typedef int data_t;typedef struct node{ data_t data; //数据域 struct node *front; //前指针域 struct node *next; //后指针域}dlistnode; //双链表节点ex原创 2020-11-24 18:37:03 · 135 阅读 · 1 评论 -
02 -- 单链表
>>注意:单链表操作时,只知道表头与插入的值1>> linklist.h#ifndef __LINKLIST_H__#define __LINKLIST_H__#include <stdio.h>#include <stdlib.h>typedef int datatype;typedef struct node{ //单链表一个节点 = 数据域 + 指针域 datatype data; struct node *next;}lis原创 2020-11-24 18:01:17 · 153 阅读 · 0 评论 -
01-顺序表
问:为什么学数据结构(DS = data struct)答:帮助软件开发更好的数据模型,让数据在内存中的操纵更加高效DS = (D,R) //D为数据元素的集合 -- R为D上关系的集合D = {2I+1 | i = 0,1,2,3,4}R = {<1,3> , <3,5> , <5,7> , <7,9> }逻辑结构 = 集合结构,线性结构,树形结构,图形结构存储结构 = 顺序存储 , 链式存储 , 索引存储 , 散列存储原创 2020-11-24 16:43:45 · 186 阅读 · 0 评论 -
#include 「stddef.h」
#include <stdlib.h>#include <stdio.h>#include <stddef.h>/*offsetof的用法{ 1:offsetof(struct 结构体名 , 结构体中的变量); 2:作用将结构体中的各个变量的字节数与空间位置返回给程序员! }NULL的用法{ NULL = (int*)0 = 0; NULL可以指代空指针,也能指代数字0;}*/void STDDEF_TEXT(){ struct原创 2020-07-05 10:10:47 · 1044 阅读 · 0 评论 -
#include [stdarg.h]
#include <stdio.h>#include <stdlib.h>#include <stdarg.h>/*注意:{ 1:va_list是一个堆栈结构体,准备接收"..."接收到的参数! 2:va_start(va_list类型变量,参数个数) ;初始化va_list结构体堆栈的深度! 3:va_arg(va_list类型变量,数据类型) ; 出栈符合该数据类型的下一个参数! 4:va_end(va_list类型变量) ;释放va_list类型原创 2020-07-04 08:09:03 · 905 阅读 · 0 评论 -
#include 「stdlib.h」
#include <stdlib.h>#include <stdio.h>/**/void Lib_Text1(){ char* Str_Number = "3,14"; double Digital_Number= atof(Number); printf("%lf", Digital_Number);}void STDLIB_TEXT(){ //atof()使用方法 Lib_Text1();}原创 2020-07-04 08:08:33 · 1763 阅读 · 0 评论 -
#include「signal.h」
#include<stdio.h>#include<stdlib.h>#include<signal.h>/*signal(参数一,参数二)的用法: 1:参数一:检测到的信号类型 { SIGABRT = 程序异常终止; SIGINT = 用户键盘产生的系统中断 SIGSEGV = 非法访问存储器 } 2:参数二:中断信号的处理方式 { SIG_DFL = 中断默认处理 SIG_IGN = 忽视信号 } .原创 2020-07-04 08:07:44 · 1447 阅读 · 0 评论 -
#include「setjmp.h」
#include<stdio.h>#include<stdlib.h>#include<setjmp.h>/*@作用: 1:C语言中不能使用goto跳转到另一个函数中的具体某处;\ 但提供了两个函数——setjmp 和 longjmp可以提转到任意程序的任意位置 2:通常作为异常处理机制!@结构体jmp_buf@setjmp()与longjmp()的使用 --> 通俗解释:先调用setjmp(),set_buf记录当前的位置,\再调用longj原创 2020-07-04 08:07:00 · 331 阅读 · 0 评论 -
#include「math.h」
#include<stdio.h>#include<stdlib.h>#include<math.h>#define Π 3.14159265/*@注意 1:math.h所有函数的返回值与传参都是double 2:Π的标准值:3.14159265 //多一位少一位都不行 3:一度=Π/180 4:e = 2.718282 5:log() //默认e为对数 6:函数传递单个地址用&就能ok ; 传递系列地址用指针; 7:pow(x,y) --原创 2020-07-04 08:06:17 · 5242 阅读 · 0 评论 -
#include「locale.h」
#include<stdio.h>#include<stdlib.h>#include<locale.h>/*@setlecale(LC_ALL,"")的作用:对程序进行地域设置(改变程序环境例:字符集编码,日期格式,货币格式...)/查看程序的地域设置信息@参数二:"" --> 根据系统语言选择程序环境 ,"ch-ZH" --> 中国 , "en-GB" --> 美国@参数一:LC_ALL --> 参数二的地域选择影响到字符.原创 2020-07-04 08:05:36 · 594 阅读 · 0 评论 -
#include 「limits.h」
#include <stdio.h>#include <float.h>#include <limits.h>/*@作用:方便查阅数据类型的数据范围!*/void LIMITS_TEXT(){ CHAR_MAX; //最大字符 = schar_max = 最大有符号字符 = 127 CHAR_MIN; //最小字符 = schar_min = 最小有符号支付 = 128 SHRT_MAX; //short最大值 SHRT_MIN; //原创 2020-07-04 08:04:55 · 1200 阅读 · 0 评论 -
#include 「errno.h」
#include <stdio.h>#include <errno.h>#include <string.h>/*@前提须知: 1:C 标准库的errno.h头文件定义了整数变量:errno 2:errno初始为int 0; 3:error == x --> x类型的错误 Value of errno: 0 Error opening file: No error Value of errno: 1 Error openin原创 2020-07-04 08:03:31 · 2175 阅读 · 0 评论 -
#include 「stdio.h」
#include <stdio.h>#include <stdlib.h>#include <stdarg.h>char Array[100];/* //注意:库函数一般返回0代表成功,-1代表失败 size_t --> sizeof的返回的无符号整型的值 FILE --> 缓存文件流(注意:指针类型) fops_t --> 缓存文件的位置! NULL --> 0 / 空指针 宏: NULL --> 空指针原创 2020-07-05 10:10:37 · 5849 阅读 · 2 评论 -
#include 「stdlib.h」
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>/* 1:atof() { 作用:"数字" --> 数字 注意:返回值为double; } 2:atoi() { 作用:"数字" --> 数字 注意:返回值为int; } 3:atol() { 作用:"数字" --> 数字 注意:返回值原创 2020-07-05 10:10:19 · 4377 阅读 · 0 评论 -
#include 「string.h」
#include <stdio.h>#include <stdlib.h>#include <string.h>/* 1:memchr() { 1:void *memchr(const void *str, int c, size_t n) 2:str=字符串的前 n 个字节 3:c = 所需寻找的字符 4:n = 查找的长度 返回值:第一次出现字符 c的地址 作用:用来截取字符串并记录下新的指针,并保留原来的字符串,例如{"hell原创 2020-07-05 10:10:04 · 1389 阅读 · 0 评论 -
#include 「time.h」
#include <stdio.h>#include <stdlib.h>#include <time.h>/* 注意: { 1:struct tm { int tm_sec; 秒,范围从 0 到 59 int tm_min; 分,范围从 0 到 59 int tm_hour; 小时,范围从 0 到 23 int tm_mday; 一月中的第几天,范原创 2020-07-05 10:09:49 · 1390 阅读 · 0 评论 -
#include 「ctype.h」
#include <stdio.h>#include <ctype.h>/*技能提升:scanf_s( ) --> 安全的scanf函数, 第三个参数要加上最大获取多少个数据例如: char Char;scanf_s("%c", &Char,1);*//*@作者:杨沁洁;@文件名:Ctype_text.c@作用:使用Ctype.h库@int isalnum(){ 判断是否是'字母',"英文",'单个数字',"数字组合"!}@in原创 2020-07-04 08:01:36 · 1189 阅读 · 0 评论 -
#include 「assert.h」
#include <stdio.h>#include <assert.h>/*@作者:西红柿爆炒鸡蛋;@作用:使用assert.h库@assert():{ 1:标准合法检查函数! 2:发现错误Asset failed,控制台打印检查原则!} *///函数功能:对输入的数据检查是否合法!void ASSET(){ int a; printf("请输入一个正整数: "); scanf_s("%d", &a); //assert(a >原创 2020-07-04 07:58:30 · 3763 阅读 · 0 评论