课程总结
本科期间课程总结
From now on...
脑阔痛
展开
-
class类与对象(二)
对象数组 将一系列的对象存放到一个数组里 建立对象数组的时候,有几个数组成员就要调用几次构造函数 #对只有一个数据成员的类,可以用只有一个参数的构造参数或者不带参数的构造函数来赋值 class exam{ private: int x; public: exam(){x=123;} exam(int n){x=n;} }; exam ob1[4]={11,22,33,44...原创 2019-10-12 09:58:57 · 202 阅读 · 0 评论 -
《c++面向对象程序设计方法》第二章 c++基础
1.const修饰符 这个东西以前就用过,定义常量,只能在定义时赋值,之后面不能修改了。 int型变量的常量声明可以直接写成constx; const可以和指针一起使用,一般有以下三种组合: (1)指向常量的指针: const char* pc = "abc"; 不能修改pc指向的字符串的成员pc[i] 的值,但是可以修改指针pc所指向的地址 pc[1]='x' X ...原创 2019-10-06 22:17:02 · 211 阅读 · 0 评论 -
单链表的操作和合并
带有头结点的单链表的操作 包含的操作有: 对一条链表进行操作 1、初始化,建立头节点 LinkList init(LinkList L) 2、头插法插入链表节点 Status insert_head(LinkList L) 3、尾插法插入链表节点 Status insert_tail(LinkList L) 4、返回第一个值为e的节点的地址 LNod...原创 2019-10-07 19:45:48 · 411 阅读 · 1 评论 -
字符链栈实现简单的括号匹配检验
只能用来判断 [ ] ( ) 四种括号 #include<stdio.h> #include<stdlib.h> #include<string.h> #define OK 1 #define ERROR 0 typedef int Status; typedef struct snode{ char sign; str...原创 2019-10-23 20:38:14 · 354 阅读 · 0 评论 -
简单的迷宫问题 ——链栈实现
迷宫问题直接dfs或者bfs多easy,非要用自己搞的链栈。。。。 不过思想很类似搜索 #include<stdio.h> #include<stdlib.h> #define OK 1 #define ERROR 0 typedef int Status; struct node{ int x; int y; }; typedef struct s...原创 2019-11-03 10:55:26 · 1076 阅读 · 2 评论 -
数据结构 多种内部排序算法的应用
输入学生数据,每个学生有学号、姓名、成绩,无序输入 按照学生的成绩 对学生进行排序 这里有8个算法(有空会修改为9个) 有基于插入的 直接插入排序 二分寻找插入排序 希尔排序 有基于交换的 冒泡排序 快速排序 有基于选择的 简单选择排序 堆排序(树形选择排序) 有基于合并的 归并排序 还有一个可能会因为关键字类型而限制的简单暴力 桶排序 这些都是基...原创 2019-12-22 22:11:51 · 236 阅读 · 0 评论 -
循环链表解决带密码的约瑟夫环问题
约瑟夫环 什么是约瑟夫环? 这里用循环链表实现一个带密码的约瑟夫环 意思是有n个人,编号1-n,他们每个人手里拿着属于自己的密码。大家按照编号坐成一圈,然后给定一个数m,然后大家从头进行0-m报数,报到m的人出列,交出密码,剩余的人从这里开始继续报数,规则一样...直到全部出列,问你最后的密码是什么? easy // 有头结点循环链表实现约瑟夫环问题 #include<std...原创 2019-10-19 15:55:12 · 1913 阅读 · 0 评论 -
单链表实现一元多项式的的加减操作
多项式的加减原理就是链表的合并 ,注意二级指针的使用 也需要注意一些简化代码的技巧的使用 #include<stdio.h> #include<stdlib.h> #include<math.h> #define OK 1 #define ERROR 0 typedef int Status; typedef struct polynode{ f...原创 2019-10-18 20:31:54 · 1041 阅读 · 0 评论 -
简单的模拟循环队列
//循环队列 #include<stdio.h> #include<stdlib.h> #define OK 1 #define ERROR 0 typedef int Status; typedef int Elemtype; typedef struct{ int* base; int front; int rear; int size; ...原创 2019-10-29 18:36:22 · 178 阅读 · 0 评论 -
单链表结合结构体 实现栈的操作
#include<stdio.h> #include<stdlib.h> #define OK 1 #define ERROR 0 typedef int Status; typedef struct snode{ int data; struct snode* next; }snode; typedef struct linkstack{ snode* t...原创 2019-10-22 21:24:24 · 189 阅读 · 0 评论 -
链栈实现简单的计算器功能
输入的格式限定有待完善 #include<stdio.h> #include<stdlib.h> #include<string.h> #include<iostream> using namespace std; const int inf=0x3f3f3f3f; #define OK 1 #define ERROR 0 typedef i...原创 2019-10-26 20:04:48 · 941 阅读 · 0 评论