自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 问答 (1)
  • 收藏
  • 关注

原创 C++二进制文件读写

/*文件内容name gradea 50b 60c 80d 100e 120f 30*/#include<iostream>#include<algorithm>#include<string>#include<fstream>#include<sstream>using namespace std;#define MaxSize 10struct Grade{ string name; int num; bo

2021-12-21 19:00:42 185

原创 堆排序。。

#include<iostream>#include<algorithm>#define MaxSize 6//这里单纯指个数 #define INF 0x7fffffffusing namespace std;int num[MaxSize+1]={INF,5,7,2,3,14,10};//从1开始存,后面比较好算父子节点位置 void HeapInsert(){//只用于构建插入 //新插入的数上升 for(int i=1;i<MaxSize+1;i++){

2021-12-14 19:18:13 891

原创 简单选择排序

#include<iostream>#include<algorithm>#define INF 0x7fffffffusing namespace std;#define MaxSize 6int num[MaxSize]={10,5,4,9,3,8};int SelectMinKey(int i);void SelectSort(){ for(int i=0;i<MaxSize;i++){//从前往后计数,已经选择了多少个最大//次大值元素 int j

2021-12-13 22:02:42 409

原创 快速排序。

#include<iostream>#include<algorithm>using namespace std;#define MaxSize 6int num[MaxSize]={10,5,4,9,3,8};int Partition(int low,int high){//将num[0]设计为中转站 num[0]=num[low];//这里是为了在low留出一个空位 int pivotkey=num[0]; while(low<high){ //这

2021-12-13 21:39:12 80

原创 冒泡排序s

#include<iostream>#include<algorithm>using namespace std;#define MaxSize 6int num[MaxSize]={10,5,4,9,3,8};void bubblesort(){ int i=MaxSize-1;bool flag=true;//true表示发生了交换 //这里设置为true是为了初始化 //进入循环 while(i>0&&flag){//倒退到i=1更合理 /

2021-12-13 21:00:32 454

原创 希尔排序s

void ShellSort(){//length int interval=length/2; while(interval>=1){ for(int i=interval;i<length;i++){//从0储存,0~interval-1为有序,interval为第一个无序元素 int temp=num[i];int j=i; while(j-interval>=0&&num[j-interval]>temp){ num[j]=num

2021-12-13 16:01:38 246

原创 二叉树的迭代器(以accumulate函数作为测试用例)

//由于二叉树的构建中,节点只支持0~9,故accumulate暂时只支持0~9的运算//输入格式为前序遍历,需要输入每一个空节点,以"#"的形式,eg:1234##5##6#7##89#1##2##//再讲一句,我真厉害!~~~ #include<stack>#include<iostream>#include<algorithm>using namespace std;struct Node { int value; Node *le

2021-12-08 00:00:00 350

原创 哈希线性再散列

#include<iostream>#define length 15using namespace std;int HT[length];int search(int* HT, int key){ int HO = key % 11; if (HT[HO] == -999) return -1; else if (HT[HO] == key) return HO; else{ for (int i = 1; i < length; i++) { int H

2021-12-05 19:36:02 61

原创 归并排序‘

#define MaxSize 500#include<iostream>using namespace std; int A[MaxSize];//全局变量似乎不能用引用 void Merge(int A[],int p,int q,int r){ int left[MaxSize]; int right[MaxSize]; int count_1=0; int count_2=0; for(int i=p;i<=q;i++) { left[count_1++]

2021-11-28 20:02:44 87

原创 插入排序。

#define MaxSize 500#include<iostream>using namespace std; int insert_num[MaxSize];int main(void){ int temp; int count=5; int flag=0; for(int i=0;i<count;i++) { cin>>temp; insert_num[i]=temp; } for(int i=0;i<count;i++) {

2021-11-28 20:02:17 328

原创 realloc使用

#include<stdio.h>#include<stdlib.h>#define LIST_INIT_SIZE 500#define LIST_INCREMENT 50#define OVERFLOW -1#define OK 1#define status int#define ElemType inttypedef struct SqList{ ElemType *elem; // 存储空间基址 int length; //当前长度

2021-11-24 10:53:18 314

原创 归并排序。

#define MaxSize 500#include<iostream>using namespace std; int A[MaxSize];//全局变量似乎不能用引用 void Merge(int A[],int p,int q,int r){ int left[MaxSize]; int right[MaxSize];//需要临时数组,因为不能无序覆盖 int count_1=0; int count_2=0; for(int i=p;i<=q;i++) {

2021-11-24 10:31:02 82

原创 拓扑排序、

#include <iostream>#include <stack>using namespace std;#define MAX_VERTEX_NUM 26typedef struct ArcNode{ int adjvex; struct ArcNode *nextarc; ArcNode(){nextarc=NULL;}}ArcNode;//链表中的节点 typedef struct VNode{//

2021-11-22 21:59:15 613

原创 SPFA.

#include<iostream>#include<queue>#define MaxSize 501//最大顶点数 #define ElemVex int//顶点编号的表示类型 #define INF 0x7fffffff#include<string>using namespace std;int vex,arc;bool vis[MaxSize];//记录队列中是否存在该节点int in_queue[MaxSize]; //表结构struct

2021-11-21 13:28:28 488

原创 Floyed

#include<iostream>#define MaxSize 501//从1计数,符合节点输入规则 #define ElemValue int#define ElemVex int#define INF 0x7fffffffusing namespace std;ElemValue graph[MaxSize][MaxSize];//邻接矩阵ElemValue dis[MaxSize][MaxSize];//最短路径信息ElemVex path[MaxSize][MaxSi

2021-11-20 20:54:10 284

原创 Dijkstra

#include<iostream>#include<string>#define MaxSize 501#define ElemValue int#define EdgeValue int#define INF 0x7fffffffusing namespace std;struct Dis{ bool vis; ElemValue value; string path; Dis(){ vis=false; value=INF; path="";

2021-11-20 14:34:35 164

原创 学生选课、

```bash#define ClassNum 4#define MaxSize 100//输入的最大可能学生数 using namespace std;#include<iostream>#include<cstring> class Student{ private: char* name;//名字 int stu_num;//学生序号 ,从0开始 public:// Student()=default;//用于为char*分配空间 Stud.

2021-11-20 13:31:09 280

原创 DFSBFS

#include<iostream>#include<algorithm>#define MaxVertexNum 2005 //边的最大值 #define MaxSize 505 //顶点数目的最大值 int sort_linklist[MaxSize];int count_1;using namespace std; bool visBFS[MaxSize];bool visDFS[MaxSize];bool flag[5010];//记录这个边是否输入过,

2021-11-20 13:29:59 823

原创 Prim实现

#include <iostream>using namespace std;#define INFINITE 0x7fffffff #define VertexData unsigned int //顶点数据#define vexCounts 501//顶点数量int AdjMat[vexCounts][vexCounts];int vex,arc;int sum;struct node{ VertexData data;//下一个连接节点 unsigned

2021-11-20 13:29:18 52

原创 计算器实现

#define ResultType double#include<iostream>#include<vector>#include<string>using namespace std;/*********************建立表达式二叉树************/ //定义表达式树typedef int TreeElemType;typedef struct TreeNode { TreeElemType data;//可以将运算符转化储存,

2021-11-20 13:28:28 642

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除