- 博客(14)
- 收藏
- 关注
原创 数据结构:N之后的问题和哈夫曼
N后问题:在n×n格的棋盘上放置彼此不受攻击的n个皇后,按照国际象棋的规则,皇后可以攻击与之处在同一行或同一列或同一斜线上的棋子,请输出皇后的位置以及对应皇后的解法个数。照搬代码#include<stdio.h>#include<malloc.h>#include<math.h>/**place it there ,application*/bool place(int* paraSolution,int paraT){ i..
2022-05-28 20:46:32
504
原创 数据结构:二叉树
一、二叉树的定义与基本操作定义:把满足以下两个条件的树型结构叫做二叉树(BinaryTree):(1)每个结点的度都不大于2;(2)每个结点的孩子结点次序不能任意颠倒。由此定义可看出,一个二叉树中的每个结点只能含有0、1或2个孩子,而且每个孩子有左右之分。位于左边的孩子叫做左孩子,位于右边的孩子叫做右孩子。代码:#include <stdio.h>#include <malloc.h>#define QUEUE_SIZE 5/* * ...
2022-05-24 18:51:51
374
原创 数据结构:二维数组和压缩矩阵
二维数组的定义:类型 数组名[行号][列号]矩阵相乘需要前面矩阵的行数与后面矩阵的列数相同方可相乘。将前面矩阵的每一行分别与后面矩阵的列相乘作为结果矩阵的行列。第一个的列数等于第二个的行数,如:2X3与3X2的结果为2X2二维数组和矩阵乘法#include<stdio.h>#include<malloc.h>#include<stdlib.h>#define ROWS 4#define COLUMNS 5/**two dim...
2022-05-19 18:44:46
313
原创 数据结构:链队列和循环队列
1.队头(front):允许删除的一端 队尾(rear):允许插入的一端2.空队列:不含任何元素的空表3.队列的特点:先进先出链队列:#include<stdio.h>#include<malloc.h>typedef struct LinkNode{ int data; LinkNode* next;}*LinkNodePtr;typedef struct LinkQueue{ LinkNodePtr front; LinkNodePtr ..
2022-05-17 13:55:42
161
原创 数据结构:累加的递归实现,汉诺塔问题
累加的递归实现#include<stdio.h>/**recursive addition*/int addTo(int paraN){ int tempSum; printf("entering addTo(%d)\r\n",paraN); if(paraN<=0){ printf("return 0\r\n"); return 0; } else{ tempSum = addTo(paraN-1)+paraN; printf("return %
2022-05-12 13:07:17
181
原创 数据结构:栈的应用 表达式求值
借鉴于他人代码#include <stdio.h>#include <stdlib.h>#include <ctype.h> #define Maxsize 100typedef int dataType; typedef struct Stack{ dataType *top; dataType *base; int stacksize;}sqstack;void create(sqstack *s){ s->base=
2022-05-10 19:42:24
397
原创 数据结构:栈的应用括号的匹配
照搬代码#include <stdio.h>#include <malloc.h>#define STACK_MAX_SIZE 10/** * Linear stack of integers. The key is data. */typedef struct CharStack { int top; int data[STACK_MAX_SIZE]; //The maximum length is fixed.} *CharStackPt
2022-05-10 16:04:00
99
原创 数据结构:栈
照搬代码#include<stdio.h>#include<malloc.h>#define STACK_MAX_SIZE 10/**Linear stack of integers. The key is data.*/typedef struct CharStack{ int top; int data[STACK_MAX_SIZE];}*CharStackPtr;/**Output the stack.*/void outputStac
2022-05-10 15:18:57
293
原创 数据结构:多向式的加法
照搬代码#include<stdio.h>#include<malloc.h>/***Linked list of integers. The key is data.The key is sorted in non-descending order.*/typedf struct LinkNode{ int coefficient; int exponent; struct LinkNode *next;}*LinkList, *Nodeptr;/**
2022-05-05 20:50:22
94
原创 数据结构:静态链表
照搬代码#include <stdio.h>#include <malloc.h>#define DEFAULT_SIZE 5typedef struct StaticLinkedNode{ char data; int next;} *NodePtr;typedef struct StaticLinkedList{ NodePtr nodes; int* used;} *ListPtr;/** * Initialize the list wi
2022-05-03 14:04:00
110
1
原创 数据结构:双向链表
照搬代码#include <stdio.h>#include <malloc.h>/** * Double linked list of integers. The key is char. */typedef struct DoubleLinkedNode{ char data; struct DoubleLinkedNode *previous; struct DoubleLinkedNode *next;} DLNode, *DLNodePtr;/
2022-05-03 13:35:08
516
1
原创 数据结构:单链表
代码照搬#include <stdio.h>#include <malloc.h>/** * Linked list of characters. The key is data. */typedef struct LinkNode{ char data; struct LinkNode *next;} LNode, *LinkList, *NodePtr;/** * Initialize the list with a header. * @retu
2022-04-29 13:25:25
877
原创 【无标题】数据结构1:顺序表
代码: #include <stdio.h>#include <malloc.h>#define LIST_MAX_LENGTH 10/** * Linear list of integers. The key is data. */typedef struct SequentialList { int actualLength; int data[LIST_MAX_LENGTH]; //The maximum length is fix..
2022-04-25 19:41:07
110
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅