随笔分类 - 考研 / 考研数据结构
摘要:在 C++ 中,static 和非 static 的变量在作用域、生命周期和初始化方面有一些重要的区别。下面详细解释这两种变量的不同之处: 非 static 变量 int i0 = 123; 作用域:变量 i0 的作用域是它所在的代码块或函数。它只能在定义它的代码块内访问。 生命周期:每次进入代码块
阅读全文
摘要:字符串 #include <stdio.h> #include <malloc.h> #include <stdbool.h> #define MaxSize 100 /*静态串的定义*/ typedef struct{ /*串的最大长度+ 一个'\0',并且从下标1开始存储*/ char cha[
阅读全文
摘要:顺序队列的操作 #include <stdio.h> #include <stdlib.h> #include <stdbool.h> typedef int ElemType; /*链式队列的节点*/ typedef struct LinkNode{ /*数据域*/ ElemType data;
阅读全文
摘要:顺序队列的操作 #include <stdio.h> #include <stdlib.h> #include <stdbool.h> typedef int ElemType; #define MaxSize 50 /*顺序队列的类型定义*/ typedef struct { /*用一维数组存放队
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> #include <stdbool.h> typedef int ElemType; /*栈的链式存储类型*/ typedef struct StackNode{ /*数据域*/ ElemType data; /*指针域*
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> #include <stdbool.h> typedef int ElemType; /**/ #define MaxSize 50 /**/ typedef struct { ElemType data[MaxSize]
阅读全文
摘要:1.定义一个双链表 #include <stdio.h> #include <stdlib.h> #include <stdbool.h> typedef int ElemType; /* 定义一个单链表 */ typedef struct DNode { /*数据域*/ ElemType data
阅读全文
摘要:单链表的创建:头插法 #include <stdio.h> #include <malloc.h> #include <stdbool.h> typedef int ElemType; /*定义一个单链表*/ typedef struct LNode{ ElemType data; /*下一个元素的
阅读全文
摘要:顺序表的初始化:静态分配 /*指定 int 的别名 */ typedef int ElemType; /*数组的最大容量*/ #define MaxSize 50 typedef struct Sqlist{ ElemType data[MaxSize]; int length; } Sqlist;
阅读全文
摘要:#include <stdio.h> #include <malloc.h> /** * 1.定义一个值传递函数 * @param a 变量值 * @param b 变量值 */ void swap_value(int a , int b){ int temp; temp =a; a=b; b=te
阅读全文
摘要:#include <stdio.h> #include <malloc.h> int main() { /*创建静态数组*/ int a[5]; a[0]=0; a[1]=1; int b[]={1,2,3,4}; typedef struct Student{ int age; }Student;
阅读全文
摘要:#include <stdio.h> int main() { /*定义一个结构体*/ struct Student{ int age; short name; }; /*使用这个结构体定义一个新的变量*/ struct Student chengqiang; /* typedef:给数据类型起一个
阅读全文
摘要:#include <stdio.h> int main() { // 定义一个变量a=150 int a = 150; printf("打印变量a:%d\n", a); // 定义一个指针变量,用于存放变量的地址 int *p; // p的值 = a的地址 p = &a; // 打印地址,使用%p格
阅读全文

浙公网安备 33010602011771号