自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

热心市民小黎的博客

最美的不是下雨天

  • 博客(63)
  • 收藏
  • 关注

原创 C++ primer_5th_chapter4 problem_solving

4.1:1054.2:*(vec.begin()),*(vec.beign())+14.3:可以接受,因为遵循开发规范编写的代码,出现程序潜在缺陷的几率比较小,而代码生成效率很重要4.4:((12/3)*4)+((5*15)+((24%4)/2))=91代码验证:#include<iostream>using namespace std;int...

2019-03-07 12:21:51 199

原创 第二讲-数据库系统的结构抽象与演变

一、数据库系统的标准结构 1.数据库管理的分层抽象External Level = User Level Conceptual Level = Logic Level Internal Level = Physical Level2.模式、视图/数据模式(Schema):对数据库中数据进行的一种结构性的描述,所观察到数据的结构信息 视图(View)/数据(Data):某一种...

2019-01-05 18:38:46 546

原创 第一讲-数据库初探

1.什么是数据库?collection of related data2.什么是table?以按行按列形式组织及展现的数据抽象:理解,区分,命名,表达表名+表标题=关系模式;表名+表标题(格式)+表内容(值)=表/关系3.数据库有了table的概念的之后,相互有关联关系的表的集合。即表内的数据是相互关联的,表与表之间也是相关的4.什么是数据库系统(DBS)?由以下5...

2019-01-04 17:35:00 256

原创 Heap_study

Heap是一种基于完全二叉树的数据结构,形式上是保证每个根节点的数值都大于(小于)他的两个孩子节点,由于是基于完全二叉树的数据结构,我们可以利用数组来实现相关操作代码:const int maxn=100;int n;//结点数量 int heap[maxn];//因为堆基于完全二叉树,所以我们用数组表示//对heap数组在[low,high]范围内进行向下调整//其中low为欲...

2018-09-07 17:36:47 141

原创 质数相关

第一个函数是判断一个数是否是质数bool isPrime(int n){ if(n<=1) return false; int sqr=(int)sqrt(1.0*n);//根号n for(int i=2;i<=sqr;i++) { if(n%i==0) return false; } return true;}第二个函数快速构造质数表,函数的...

2018-09-07 16:56:00 132

原创 分数处理和大数处理

分数处理我们为分数设置一个结构体,结构体内设置两个变量,一个分子,一个分分母struct fraction{ long long up;//分子 long long down;//分母 };接下来是分数的加减乘除运算,我们以加法为例,体会一下分为分子分母的好处fraction frac_add(fraction a,fraction b)//分数相加,其余运算可以类比 ...

2018-09-07 15:29:41 379

原创 最大公约数与最小公倍数

一般来说,我们用欧几里得算法来求最大公因数,数学原理请见:欧几里得算法原理有点绕,但其实算法实现很简单,利用递归实现,代码如下:int gcd(int a,int b)//最大公因数 { if(b==0) return a; else return gcd(b,a%b);}求得最大公因数之后,最小公倍数的求法就非常简单了,两数相乘再除以最大公因数即可int lc...

2018-09-07 15:20:19 164

原创 单源最短路径_Dijkstra_study

邻接矩阵版const int maxn=1010;const int INF=0x3f3f3f3f3f;int n,G[maxn][maxn];int d[maxn];//d[v]表示初始点s到点v的最短路径bool vis[maxn]={false};int pre[maxn];//记录最短路径 void Dijkstra(int s)//s是起点{ fill(d,d+m...

2018-09-07 10:58:55 143

原创 PATA 1018 Public Bike Management(30 分)解题报告

1018 Public Bike Management(30 分)There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and retu...

2018-09-07 10:39:14 518

原创 PATA 1021 Deepest Root(25 分)解题报告

1021 Deepest Root(25 分)A graph which is connected and acyclic can be considered a tree. The hight of the tree depends on the selected root. Now you are supposed to find the root that results in a hi...

2018-09-06 14:34:04 930

原创 PATA 1013 Battle Over Cities(25 分)解题报告

1013 Battle Over Cities(25 分)It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We ...

2018-09-06 11:57:46 554

原创 PATA 1076 Forwards on Weibo(30 分)解题报告

1076 Forwards on Weibo(30 分)Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed wit...

2018-09-06 11:22:58 597

原创 PATA 1034 Head of a Gang(30 分)解题报告

1034 Head of a Gang(30 分)One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a ...

2018-09-05 11:01:22 285

原创 PATA 1098 Insertion or Heap Sort(25 分)解题报告

1098 Insertion or Heap Sort(25 分)According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort remov...

2018-09-05 09:54:33 785

原创 PATA 1107 Social Clusters(30 分)解题报告

1107 Social Clusters(30 分)When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A social cluster is a set of ...

2018-09-04 21:32:56 581

原创 DFSTrave_study

今天是比较正经的图遍历,纯粹的只讲怎么遍历一张图,DFS_study讲的是用DFS的思想去解决问题(一次性探索一条路径到底的思想)const int INF=0x7fffffff; int n,G[maxn][maxn];//n为顶点数,maxn为最大顶点数 bool v[maxn]={false};//如果顶点i已经被访问,则v[i]=true;void DFS(int u,int...

2018-09-04 21:18:31 120

原创 PATA 1066 Root of AVL Tree(25 分)解题报告

1066 Root of AVL Tree(25 分)An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by ...

2018-09-04 14:40:53 549

原创 PATA 1099 Build A Binary Search Tree(30 分)解题报告

1099 Build A Binary Search Tree(30 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys ...

2018-09-04 12:00:36 158

原创 PATA 1064 Complete Binary Search Tree(30 分)解题报告

1064 Complete Binary Search Tree(30 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys...

2018-09-04 11:51:31 472 4

原创 PATA 1043 Is It a Binary Search Tree(25 分)解题报告

1043 Is It a Binary Search Tree(25 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys ...

2018-09-04 11:36:25 229

原创 PATA 1004 Counting Leaves(30 分)解题报告

1004 Counting Leaves(30 分)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one...

2018-09-04 11:13:10 743

原创 PATA 1106 Lowest Price in Supply Chain(25 分)解题报告

1106 Lowest Price in Supply Chain(25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starti...

2018-09-04 10:56:32 164

原创 PATA 1094 The Largest Generation(25 分)解题报告

1094 The Largest Generation(25 分)A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation w...

2018-09-04 10:37:47 113

原创 BST_study

关于BST,文字性的表述我们日后再做补充,今天在这里给出基本操作的代码#include<iostream>#include<cstdio>#include<string>#include<queue>#include<stack>#include<algorithm> #include<cmath&gt

2018-09-03 17:53:10 125

原创 PATA 1103 Integer Factorization(30 分)解题报告

1103 Integer Factorization(30 分)The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K−P f...

2018-09-03 12:02:28 491

原创 PATA 1090 Highest Price in Supply Chain(25 分)解题报告

1090 Highest Price in Supply Chain(25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Start...

2018-09-03 11:54:04 205

原创 DFS_study

DFS在实际中的应用关键是设置合理的递归边界和递归式,例如在PATA 1103中,要考虑数可以重复的情况,就不能想当然的在所有递归入口都把index+1,有一个入口的index是不会变化的,同时要注意剪枝,降低算法的时间复杂度,递归的初始入口的设置也值得探讨PAT 1103:1103 例1,背包问题 有n件物品的重量为w[i],价值为c[i],现在需要取出若干件物品放入背包使得在选...

2018-09-03 11:02:30 141

原创 PATA 1079 Total Sales of Supply Chain(25 分)解题报告

1079 Total Sales of Supply Chain(25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Startin...

2018-09-03 10:56:59 610

原创 PATA 1091 Acute Stroke(30 分)解题报告

1091 Acute Stroke(30 分)One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MR...

2018-09-03 10:36:11 541

原创 BFS_study

 例1给出一个m*n矩阵,矩阵中的元素是0或1称位置(x,y)与其上下左右四个位置是相邻的如果矩阵中有若干个1是相邻的,那么称这些1构成了一个块请求出给定矩阵中“块”的个数矩阵如下: 0 1 1 1 0 0 10 0 1 0 0 0 00 0 0 0 1 0 00 0 0 1 1 1 01 1 1 0 1 0 01 1 1 1 0 0 0例如上面的6*7矩阵中,有...

2018-09-02 19:16:55 179

原创 Binary_Tree_初探

本节学习了二叉树,二叉树节点的定义,插入,如何建二叉树,四种遍历方式,怎么根据给定的前序/后序+中序序列来建树等等可以结合PATA1020/1086/1102进行理解//A1020 A1086 A1102#include<iostream>#include<cstdio>#include<string>#include<algorithm...

2018-09-01 14:46:12 139

原创 PATA 1097 Deduplication on a Linked List(25 分)解题报告

 1097 Deduplication on a Linked List(25 分)Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value ...

2018-08-31 17:46:55 284

原创 stack_初探

本节介绍一下STL中的stack#include<iostream>#include<cstdio>#include<stack>using namespace std;int main(){ //本节学习STL-stack,同理定义方式和其他STL容器别无二致 printf("create a stack and push 1~5\n");...

2018-08-30 21:04:56 108

原创 priority_queue_初探

不多说,懂的都懂,看代码#include<iostream>#include<cstdio>#include<queue>using namespace std;struct fruit{ string name; int price; friend bool operator <(fruit f1,fruit f2) { ret...

2018-08-30 20:36:24 88

原创 queue_初探

queue就是我们平常学的队列,STL集成了他的一些基本功能,很多函数,例如find(),erase(),等都与其他STL容器别无二致#include<iostream>#include<cstdio>#include<queue>using namespace std;int main(){ //queue是先进先出队列,只能通过front访...

2018-08-30 11:16:48 116

原创 map_初探

map是一个很有用的映射工具,底层用红黑树实现,所以也是自动有序的(按照键值key排序)#include<iostream>#include<cstdio>#include<map>using namespace std;int main(){ //map译为映射,常用的STL容器之一 //int数组是定义了一个int到int类型的映射,do...

2018-08-29 21:34:51 146

原创 string_初探

补充了一些以前不知道的string类知识#include<iostream>#include<cstdio>#include<algorithm>#include<string>using namespace std;int main(){ //substr(pos,len),返回从pos号位开始,长度为len的元素 stri...

2018-08-28 21:30:33 106

原创 set_初探

set是一个自动去重的有序容器PATA 1063是考察set的题目#include<iostream>#include<cstdio>#include<algorithm>#include<set>using namespace std;int main(){ //set是内部自动有序且不含重复元素的容器 //vector和...

2018-08-28 21:29:14 106

转载 普通数字到科学计数法的转换

这个代码的功能是把给定的数用科学计数法的方式实现代码来自于《算法笔记》P209数以string类的形式给出,返回的也是string类,并以引用方式修改了指数e,一开始e=0,其中精度n是全局变量,在函数外声明这个算法是按指定精度保留了非0的数字至于需要以什么形式输出m.xxx还是0.xxx需要根据题目情况进行讨论算法把数分成0.xxxx和m.xxxx来处理的,也就是绝对值大于1和小...

2018-08-28 21:21:48 4343

原创 PATA 1033 To Fill or Not to Fill(25 分)解题报告

1033 To Fill or Not to Fill(25 分)With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the ...

2018-08-27 22:06:56 2191

空空如也

空空如也

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

TA关注的人

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