![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
代码模板
文章平均质量分 89
HaoYuanSama
这个作者很懒,什么都没留下…
展开
-
【7050】已知散列函数为H(key)=key mod 13,冲突处理方法为外拉链法实现散列表的建立(利用插入算法实现)
#include<iostream>using namespace std;typedef struct node { node* next; int data;}LNode, * LinkList;typedef struct hashlist { int ListLength; LinkList list;}HashList;void Li...原创 2019-12-09 14:50:05 · 4495 阅读 · 4 评论 -
【7051】已知散列函数为H(key)=key%p,冲突处理方法分别为线性探测法实现散列表的建立(插入算法实现)
#include<iostream>#include<string.h>using namespace std;void Insert_HashList(int* hashlist, int ListLength, int key) { //calculate p value int p = 0; for (int i = ListLength; i ...原创 2019-12-09 14:20:41 · 4077 阅读 · 0 评论 -
【7081】利用二叉排序树的插入算法创建二叉排序树,并中序遍历该二叉树
#include<iostream>using namespace std;typedef struct node { int data; node* lChild, * rChild;}Tree,*Bitree;void CreateTreeByOrder(Bitree& t, int n) { if (t) { if (t->data &...原创 2019-12-05 13:45:14 · 895 阅读 · 0 评论 -
【7083】试编写有序表折半查找算法
#define _CRT_SECURE_NO_WARNINGS#include<iostream>using namespace std;int main() { int a; int arr[10000]; cin >> a; int i = 0; while (a != 0) { arr[i] = a; cin >>...原创 2019-12-05 13:40:43 · 745 阅读 · 0 评论 -
【7041】以有向图的邻接表为基础实现输出它的拓扑排序序列
#include<iostream>#include<queue>#include<string.h>#include<stack> using namespace std;typedef struct ArcNode { int adjvex; struct ArcNode* nextArc;}ArcNode; //边...原创 2019-12-05 13:39:35 · 838 阅读 · 1 评论 -
【7040】再有向图的邻接表存储的基础上,试设计算法计算各顶点的度,并依次输出,入度,出度,度
#include<iostream>#include<queue>#include<string.h>using namespace std;typedef struct ArcNode { int adjvex; struct ArcNode* nextArc;}ArcNode; //边节点typedef struct VNod...原创 2019-12-05 13:37:51 · 1392 阅读 · 1 评论 -
【7039】试编写算法,创建有向图邻接表,并深度优先遍历
#include<iostream>#include<queue>#include<string.h>using namespace std;typedef struct ArcNode { int adjvex; struct ArcNode* nextArc;}ArcNode; //边节点typedef struct VNod...原创 2019-12-05 13:34:58 · 425 阅读 · 0 评论 -
【7042】采用邻接表存储实现无向图的深度优先非递归遍历
#include<iostream>#include<queue>#include<string.h>using namespace std;typedef struct ArcNode { int adjvex; struct ArcNode* nextArc;}ArcNode; //边节点typedef struct VNo...原创 2019-12-05 13:33:18 · 1202 阅读 · 0 评论 -
【7043】利用邻接表实现无向图的广度优先遍历
#include<iostream>#include<queue>#include<string.h>using namespace std;typedef struct ArcNode { int adjvex; struct ArcNode* nextArc;}ArcNode; //边节点typedef struct VNod...原创 2019-11-26 17:10:18 · 808 阅读 · 3 评论 -
【6111】查找值为x的节点的所有祖先节点并输出
#include<iostream>#include<string>#include<queue>using namespace std;typedef struct node { string data; node* lChild, * rChild;}Node,*Tree;void CreateTree(Tree& ...原创 2019-11-06 11:38:21 · 742 阅读 · 0 评论 -
【6109】将两个递增有序单链表合成一个递增有序的单链表
#include<iostream>#define RESULT int#define OK 1#define ERROR 0using namespace std;typedef struct Node { int data; Node* next;}LNode, * LinkList;RESULT InitList(LinkList& L...原创 2019-11-06 11:36:26 · 1034 阅读 · 0 评论 -
【7074】求二叉树高度
#include <iostream>#include <stdio.h>#define MAXSIZE 10000using namespace std;typedef struct bitnode{ char data; struct bitnode* lChild,*rChild;}BiTNode,*BiTree;char a;...原创 2019-11-06 11:34:47 · 183 阅读 · 0 评论 -
【7075】二叉树的后序遍历
#include <iostream>#include <stdio.h>#define MAXSIZE 10000using namespace std;typedef struct bitnode{ char data; struct bitnode* lChild,*rChild;}BiTNode,*BiTree;void Cr...原创 2019-11-06 11:33:24 · 152 阅读 · 0 评论 -
【7076】二叉树的叶子节点数
#include <iostream>#include <stdio.h>#define MAXSIZE 10000using namespace std;typedef struct bitnode{ char data; struct bitnode* lChild,*rChild;}BiTNode,*BiTree;void Cr...原创 2019-11-06 11:32:05 · 172 阅读 · 0 评论 -
【7077】二叉树的层次遍历序列
#include <iostream>#include <stdio.h>#include <queue>#define MAXSIZE 10000using namespace std;typedef struct bitnode{ char data; struct bitnode* lChild,*rChild;}BiT...原创 2019-11-06 11:30:36 · 397 阅读 · 0 评论 -
【7079】中序遍历二叉树
#include <iostream>#include <stdio.h>#define MAXSIZE 10000using namespace std;typedef struct bitnode{ char data; struct bitnode* lChild,*rChild;}BiTNode,*BiTree;void Cr...原创 2019-11-06 11:28:05 · 212 阅读 · 1 评论 -
【7080】输入森林对应的二叉树的先序遍历序列,建立一颗二叉树,该二叉树就是森林的孩子兄弟表示法,输出森林的叶子节点个数
【7080】输入森林对应的二叉树的先序遍历序列,建立一颗二叉树,该二叉树就是森林的孩子兄弟表示法,输出森林的叶子节点个数二叉树节点类型为char 特殊字符为@输入ABD@@E@R@@CF@@GI@@@输出5#include<iostream>using namespace std;typedef struct node { char data; n...原创 2019-11-06 11:25:14 · 771 阅读 · 0 评论 -
【8568】打印杨辉三角形
本人有点懒,直接用了数组=。=#include<bits/stdc++.h>using namespace std;int main() { int arr[100][100]; memset(arr, 0, sizeof(arr)); arr[1][1] = 1; int n; cin >> n; for (int i = 2; i <=...原创 2019-11-06 11:19:23 · 208 阅读 · 0 评论 -
【8565】变成,采用顺序村春实现循环队列的初始化,入队,出队操作。要求输入整形数据,输入0表示结束(0不存储在栈中)
【8565】变成,采用顺序村春实现循环队列的初始化,入队,出队操作。要求输入整形数据,输入0表示结束(0不存储在栈中)输入1 2 3 4 5 6 7 8 9 0输出1 2 3 4 5 6 7 8 9 0#include<bits/stdc++.h>using namespace std;typedef struct CircleQueue { int fir...原创 2019-11-06 11:17:35 · 256 阅读 · 0 评论 -
【8564】变成,采用链式存储实现队列的初始化,入队,出队操作。要求输入整形数据,输入0表示结束(0不存储在栈中)
【8564】变成,采用链式存储实现队列的初始化,入队,出队操作。要求输入整形数据,输入0表示结束(0不存储在栈中)输入11 22 33 44 55 66 77 88 99 011 22 33 44 55 66 77 88 99 #include<bits/stdc++.h>using namespace std;typedef struct node { ...原创 2019-11-06 11:15:01 · 582 阅读 · 0 评论 -
【8562】试编写算法,采用链式存储实现栈的初始化,入栈,出栈操作。要求输入整形数据,0结束
【8562】试编写算法,采用链式存储实现栈的初始化,入栈,出栈操作。要求输入整形数据,0结束#include<bits/stdc++.h>using namespace std;typedef struct node{ node *first; node *next; int data;}SNode,*SLink;typedef struct...原创 2019-10-08 19:29:49 · 2771 阅读 · 0 评论 -
【8566】利用栈实现数制转换
【8566】利用栈实现数制转换#include<bits/stdc++.h>using namespace std;typedef struct node{ node *first; node *next; int data;}SNode,*SLink;typedef struct StackLink{ SLink top; ...原创 2019-10-08 19:32:34 · 1125 阅读 · 0 评论 -
【8569】利用栈实现表达式求值
【8569】利用栈实现表达式求值1.不使用标准库。在这种情况下比较麻烦,由于是学校的算法设计,所以只能根据数据类型分别设计函数和数据结构==,不能使用class,很烦。在这段代码之后是使用了标准库的程序#include<bits/stdc++.h>using namespace std;typedef struct nnode { nnode* first; ...原创 2019-10-08 19:41:00 · 535 阅读 · 0 评论 -
【8555】编写在非递减有序链表中插入一个元素使链表元素仍有序的函数,并利用该函数建立一个非递减有序单向链表
编写在非递减有序链表中插入一个元素使链表元素仍有序的函数,并利用该函数建立一个非递减有序单向链表#include<bits/stdc++.h>#define RESULT int#define OK 1#define ERROR 0using namespace std;typedef struct Node { int data; Node* next;...原创 2019-09-25 00:08:27 · 4033 阅读 · 0 评论 -
【Windows.h】学习日志 Dat.6 截获鼠标焦点 && 创建编辑框
截获鼠标焦点#include<Windows.h>#include<stdlib.h>#include<windowsx.h>#include<stdio.h>LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);int WINA...原创 2019-08-15 20:35:57 · 166 阅读 · 0 评论 -
【8563】试编写算法,采用顺序存储实现栈的初始化,入栈,出栈操作。要求输入整形数据,输入0表示结束。
【8563】试编写算法,采用顺序存储实现栈的初始化,入栈,出栈操作。要求输入整形数据,输入0表示结束。#include<bits/stdc++.h>using namespace std;#define MAX 100000typedef struct { int top; int bottom; int data[MAX];} MyStack;...原创 2019-10-08 19:20:18 · 1266 阅读 · 0 评论 -
【4885】设ha和ha分别是两个带附加头结点的非递增有序单链表的表头指针,试设计一个函数将这两个有序单链表合并成一个非递增有序的单链表。
设ha和ha分别是两个带附加头结点的非递增有序单链表的表头指针,试设计一个函数将这两个有序单链表合并成一个非递增有序的单链表。要求结果链表仍使用原来两个链表的存储空间切新的头结点为原来ha的头结点,不另外占用其他的存储空间。锐格提供的代码模板与答案有误,以下程序通过了本地测试#include<iostream>using namespace std;struct Node {...原创 2019-09-28 08:32:33 · 2214 阅读 · 4 评论 -
【6063】将单链表每个元素的值修改为该节点值加上后继节点值
#include<iostream>#define RESULT int#define OK 1#define ERROR 0using namespace std;typedef struct Node { int data = 0; Node *next;}LNode, *LinkList;RESULT InitList(LinkList &am...原创 2019-09-17 22:50:05 · 445 阅读 · 0 评论 -
【线性表】算法设计题
1、将两个递增的有序链表合并为一个递增的有序链表。要求结果链表仍使用原来两个链表的存储空间,不另外占用其他的存储空间,表中不允许有重复的数据#include<iostream>#include<Windows.h>#define RESULT int#define OK 1#define ERROR 0using namespace std;typedef...原创 2019-09-14 14:38:27 · 692 阅读 · 0 评论 -
【Windows.h】学习日志 Dat.8 子窗口标准化控件 && 定时器技术
//按钮#include<Windows.h>LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, i...原创 2019-08-17 11:29:21 · 212 阅读 · 0 评论 -
【Windows.h】学习日志 Dat.7 获得子窗口句柄 && 焦点应用
#include<Windows.h>//鼠标跟随只实现了前两列因为IDC不够了 XDLRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT message, WPARAM wPa...原创 2019-08-17 10:39:12 · 245 阅读 · 0 评论 -
【Windows.h】获取键盘焦点位置
获取键盘焦点位置RECT rct;HWND hwnd;hwnd = GetFocus(); //获取焦点句柄GetWindowRect(hwnd, &rct); //焦点控件的坐标原创 2019-08-15 20:38:14 · 812 阅读 · 0 评论 -
【Windows.h】学习日志 Dat.5 窗口滚动条
//system.h#pragma once#include<Windows.h>#define NUMLINES ((int)(sizeof sysmetrics/sizeof sysmetrics[0]))struct { int index; char szLabel[50]; char szDesc[100];} sysmetrics [] = { ...原创 2019-08-15 20:30:53 · 157 阅读 · 0 评论 -
【Windows.h】学习日志 Dat.4 创建移动的人物
创建移动的人物#include<Windows.h>#pragma comment(lib,"winmm.lib") //windows库与multimedia库HDC g_hdc = NULL; //设备环境句柄HDC g_mdc = NULL; //设备内存HDC g_buffdc = NULL; //缓存HBITMAP g_hS...原创 2019-07-30 11:03:10 · 152 阅读 · 0 评论 -
【Windows.h】学习日志 Dat.3 在windows窗口上输出文字 && 输出5个画刷矩形
1、在windows窗口上,输出对应【静夜思】诗句且解释?#include<Windows.h>#define WINDOW_WIDTH 800#define WINDOW_HEIGHT 600#define WINDOW_TITLE L"第三讲:windows标准输出字符与图形"HDC g_hdc = NULL;BOOL InitRes(HWND hwnd);voi...原创 2019-07-30 10:59:21 · 389 阅读 · 0 评论 -
【Windows.h】学习日志 Dat.2 连续加载图片到窗口中 && windows程序设计WinMain()函数几大操作过程
1、应用windows程序设计,实现连续加载20图处到窗口当中(图片大小1024*768)?#include<Windows.h>#include<tchar.h>#pragma comment(lib,"winmm.lib")LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPAR...原创 2019-07-30 10:56:26 · 341 阅读 · 0 评论 -
【Windows.h】学习日志 Dat.1 使用MessageBox消息框判断播放两首歌曲 && windows应用程序的执行过程
1、使用MessageBox消息框判断播放两首歌曲?#include<Windows.h>#pragma comment(lib,"winmm.lib")int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int i = Mess...原创 2019-07-30 10:54:05 · 138 阅读 · 0 评论 -
【5993】头插法建立带头结点的单链表,读入要建立单链表的节点数,输入节点值(整型),打印输出链表。
#include<iostream>#define RESULT int#define OK 1#define ERROR 0using namespace std;typedef struct Node { int data = 0; Node *next = NULL;}LNode, *LinkList;RESULT InitList(LinkL...原创 2019-09-24 23:37:25 · 1096 阅读 · 0 评论 -
【4897】设以带附加头结点的双向循环链表表示的线性表L=(a1,a2,...,an)。试写一个时间复杂度为O(n)的函数,将L改造为L=(a1,a3,...,a4,a2)
#include<iostream>using namespace std;struct Node { int data; Node* rLink; Node* lLink;};class DList {private: Node* first; Node* rear;public: DList(); ~DList(); Node* First()...原创 2019-09-17 22:58:59 · 1351 阅读 · 1 评论 -
【8560】采用单向链表实现一元多项式的存储并实现两个多项式相加并输出结果
采用单向链表实现一元多项式的存储并实现两个多项式相加并输出结果#define _CRT_SECURE_NO_WARNINGS#include<bits/stdc++.h>using namespace std;typedef struct node { node* next; int x, z;}LNode, * LinkList;int main() {...原创 2019-09-25 09:59:56 · 2478 阅读 · 0 评论