- 博客(16)
- 资源 (1)
- 收藏
- 关注
原创 宿舍管理查询软件--数据结构,c语言
#include<cstdio>#include<string>#include<iostream>#include<fstream>#include<windows.h>using namespace std;#define Max 100 int total; struct edg//构造结构体,创建学生信息的结构体数组,其中的信息包含名字,宿舍房号以及学号 。{ string name; int number; .
2020-06-10 14:46:32
4688
3
原创 二叉排序树的查找算法
#include<iostream>#include<stdio.h>#include<string>using namespace std;int flag;struct btree{ int date; btree *left, *right;}; void creathead(btree *&root){ root=new btree; cin>>root->date; root->left=ro.
2020-06-09 20:41:44
1311
原创 折半查找的算法
#include<stdio.h> #define MaxSize 20typedef struct{ int key;}RecordType; typedef struct{ int length; RecordType r[MaxSize + 1];}RecordList; int BinSearch(RecordList l, int key){ int low = 1; int high = l.length; .
2020-06-09 20:40:14
343
原创 二叉树的链式存储结构定义,二叉树的三种遍历算法
#include <stdio.h>#include <stdlib.h>#include <time.h> //二叉树节点信息struct binarytreenode{ int data; struct binarytreenode *lchild;//左子树 struct binarytreenode *rchild;//右子树};typedef struct binarytreenode BiTNode; void print( in.
2020-06-09 20:38:08
1014
原创 三元组顺序表结构的定义,矩阵的转置运算
//T(i,j)=M(j,i)#include<stdio.h>#define number 100//typedef int elemtype;typedef struct{ int i,j; int data;}triple; //3元组typedef struct{ int m,n,num; triple data[number]; int rpos[number];}tsmatrix; .
2020-06-09 20:36:26
1378
原创 循环队列的进队和出队算法
#include<stdio.h>#include<malloc.h>#define maxsize 100typedef struct queue{ int *base; int front,rear;}queue;queue q;void add(queue &q,int n){ int i; q.base=(int*)malloc(maxsize*sizeof(int)); if(n>maxsize-1) p.
2020-06-09 20:32:04
2711
原创 链队列的进队和出队算法
#include<stdio.h>#include<malloc.h>#include<stdlib.h>//#define len sizeof(qnode)typedef struct qnode{ int data; struct qnode *link;}qnode;typedef struct{ qnode *front; qnode *rear;}qlink; int initialqlink(qlink *q.
2020-06-09 20:30:41
2269
原创 链式栈的进栈、出栈算法
#include<stdio.h>#include<malloc.h>#define len sizeof(stnode)typedef struct node //list为头结点指针,link为结点,node为结点{ int data; struct node *link;}stnode,*stlink;void initialslink(stlink &top) //堆.
2020-06-09 20:28:15
2858
原创 顺序栈的进栈、出栈算法
#include<stdio.h>#define m 100typedef struct { int stack[m]; int top;}qstype;void initials(int &top) //初始化一个堆栈{ top=-1;}int emptys(int top) //判断是否为空{ return top==-1; //判断top是否等于-1,top==-1 -> return 1 || top!=-1 -&g.
2020-06-09 20:26:26
6067
1
原创 单链表的插入和删除
//单链表的插入和删除 单链表就是线性链表#include <stdio.h> #include<malloc.h> //动态存储分配typedef struct Lnode{ int data; struct Lnode *Link;}Lnode,*Linklist;Linklist create(int n){ Linklist list=(Linklist)malloc(sizeof(Lnode)); //为指针list..
2020-06-09 20:24:48
768
1
原创 实验一 顺序表的插入和删除
//顺序表前插(在第i号元素前插入一个新的元素)#include<stdio.h> //标准的输入输出头文件#include<malloc.h> //动态存储分配的需要#include<string.h> //字符数组的函数头文件#define maxnum 200typedef struct { int list[maxnum]; //线性表 int num; }qltype; //类型定义vo...
2020-06-09 20:22:05
2384
1
原创 (2)定义交通工具类Vehicle,包含虚函数Printinfo()。由其作为基类派生小车类Car、卡车类Truck和轮船类Boat。(各个派生类的信息自行定义)在main函数中定义Vehicle类的
#include<iostream>#include<string>using namespace std;class Vehicle{private: double weight;public: Vehicle() { weight=0; } Vehicle(double w) { weight=w; } virtual void printinfor() {...
2018-05-06 09:25:49
7228
原创 (1)定义猫科动物Animal类,包含虚函数 Sound( )。由其派生出猫类(Cat)和豹类(Leopard)。在main函数中定义Animal类的指针指向派生类的对象并调用Sound()函数实现多
#include<iostream>using namespace std;class Animal{public: virtual void sound() { cout<<"animal speak!"<<endl; }};class Cat:public Animal{public: virtual void sound() { cout<&l...
2018-05-06 09:24:29
8155
原创 (2)一圆形游泳池如图所示,现在需在其周围建一圆形过道,并在其四周围上栅栏。栅栏价格为35元/米,过道造价为20元/平方米。过道宽度为3米,游泳池半径由键盘输入。要求编程计算并输出过道和栅栏的造价。(
#include<iostream>using namespace std;class Circle{ private: float r; public: Circle():PI(3.1415926) { r=0; } Circle(float r):r(r),PI(3.1415926) { } void printInfor() { ...
2018-05-06 09:21:49
13850
1
原创 (1)定义一个Rectangle类,它包括两个数据成员长len和宽width,以及求面积的成员函数Area,另外定义Set函数对私有数据成员进行设置。在主函数定义一个对象,输出其面积。(可自行增加需要
#include<iostream>using namespace std;class Point{ public: Point() { len=0; width=0; } Point(float len,float width):len(len),width(width) { } void printInfor() { cout<<"len:"<...
2018-05-06 09:17:39
16658
原创 求二维数组中的最大值
#include<stdio.h>void swap(int a[5][5],int *max){ int i,j; *max=a[0][0]; for(i=0;i<5;i++) { for(j=0;j<5;j++) { if(*max<a[i][j]) *max=a[i][j]; ...
2018-03-20 22:27:40
18408
1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人