![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
文章平均质量分 57
944458473
代码是最为耐心、最能忍耐和最令人愉快的伙伴,在任何艰难困苦的时刻,它都不会抛弃你。
展开
-
1166-敌兵布阵(树状数组)
http://www.cnblogs.com/justforgl/archive/2012/07/27/2612364.html现在来说明下树状数组是什么东西?假设序列为A[1]~A[8]网络上面都有这个图,但是我将这个图做了2点改进。(1)图中有一棵满二叉树,满二叉树的每一个结点对应A[]中的一个元素。(2)C[i]为A[i]对应的那一列的最高的节转载 2017-11-04 00:41:09 · 157 阅读 · 0 评论 -
贪心 HDU.OJ 2037 今年暑假不AC
贪心(今年暑假不AC): 排完序之后时间的排列顺序为: 1 ---> 3 3 ---> 4 0 ---> 7 3 ---> 8 2 ---> 9 5 ---> 10 6 ---> 12 4 ---> 14 10 --> 15原创 2017-11-13 22:03:17 · 206 阅读 · 0 评论 -
HackerRank Between Two Sets
https://www.hackerrank.com/challenges/between-two-sets/problem#includeusing namespace std;int gcd(int a, int b){ while(b > 0){ int temp = b; b = a % b;原创 2017-11-14 19:28:16 · 410 阅读 · 0 评论 -
D.Game with Pearls
Game with PearlsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Problem DescriptionTom and Jerry are playing a game with tubes and pearls. The rule of原创 2017-11-16 23:32:49 · 179 阅读 · 0 评论 -
归并排序C++
#include#include#includeusing namespace std;void Merge(int data[], int l, int m, int r){ int i, j, k; int *pd; pd = (int *)malloc((r - l + 1) * sizeof(int)); i = l;原创 2017-12-24 17:56:39 · 263 阅读 · 0 评论 -
shell排序C++
#include#include#includeusing namespace std;void ShellSort(int data[], int n){ for(int r = n / 2; r >= 1; r /= 2) { for(int i = r; i { int temp = da原创 2017-12-24 20:45:46 · 462 阅读 · 0 评论 -
堆排序C++
#include#include#includeusing namespace std;int left(int x){ return (x }int right(int x){ return (x }void Swap(int *a, int *b){ int temp = *a; *a = *b; *原创 2017-12-26 10:13:21 · 158 阅读 · 0 评论 -
遍历二叉树C++
遍历二叉树统计二叉树结点数、叶子数、深 度。#include#include#include#includeusing namespace std;typedef struct BiTNode{ int data; int flag; struct BiTNode *Lchild,*Rchild;}BTNode,BTree原创 2017-12-28 12:52:37 · 220 阅读 · 0 评论 -
C++哈夫曼编码一例
#include#include#include#include#define MAXVALUE 200 /*权值的最大值*/#define MAXBIT 30 /*最大的编码位数*/#define MAXNODE 30 /*初始的最大的结点数*/struct haffnode{ cha原创 2017-11-22 18:09:13 · 709 阅读 · 0 评论 -
单调栈 求最大子矩阵的大小
求最大子矩阵的大小(题目)给定一个整型矩阵map,其中的值只有0和1两种,求其中全是1的所有矩形区域中,最大的矩形区域为1的数量。例如:1 1 1 0其中,最大的矩形区域有3个1,所以返回3。再如:1 0 1 11 1 1 11 1 1 0其中,最大的矩形区域有6个1,所以返回6。#include<iostream>#include<stdio.h>#include&l...原创 2018-03-14 18:26:22 · 803 阅读 · 0 评论 -
生成窗口最大值
生成窗口最大值数组[题目]有一个整型数组arr和一个大小为w的窗口从数组的最左边滑到最右边,窗口每次向右边滑一个位置。例如,数组为[4,3,5,4,3,3,6,7], 窗口大小为3时: [4 3 5] 4 3 3 6 7 窗口中最大值为5 4 [3 5 4] 3 3 6 7 窗口中最大值为5 4 3 [5 4 3] 3 6 7 ...原创 2018-03-13 01:23:27 · 363 阅读 · 0 评论 -
Leetcode4. Median of Two Sorted Arrays
Leetcode4. Median of Two Sorted ArraysThere are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity shoul原创 2017-10-14 13:06:13 · 178 阅读 · 0 评论 -
C++字符串中的空格移位
(水题)C++字符串中的空格移位题目描述输入一个字符串,将其中的所有空格都移到最后,然后输出。 输入一个字符串。 输出空格全部移到了串尾的字符串。 样例输入 a□b□c样例输出abc□□#include#includeusing namespace std;int main(){ char a[1000]原创 2017-10-20 00:27:24 · 3927 阅读 · 0 评论 -
01背包问题C
有5个物品,编号1-5,背包的总承重为10,重量分别是【2,2,6,5,4】,价值分别是【6,3,5,4,6】。结果:最大价值15。1,如果装入第i个物品时,它的重量大于背包的剩余容量,则装人前i个物品得到的最大价值和装入前i-1个物品得到的最大价是相同的,因为物品i不能装入背包,2,如果装入第i个物品时,它重量小于背包的剩余容量,则会有一下两种情况:(a)如果把第i个物品装入背包,则背包物品原创 2017-04-17 20:15:09 · 349 阅读 · 0 评论 -
哈理工oj 1612 方格问题
哈理工oj 1612 方格问题Description在一无限大的二维平面中,我们做如下假设:1、 每次只能移动一格;2、 你可以向左走,可以向右走,也可以向上走,但是不可以向下走。3、 走过的格子立即塌陷无法再走第二次;求走n步不同的方案数(2种走法只要有一步不一样,即被认为是不同的方案)。Input首先给出一个正整数T(T 接下来的T行,每行原创 2017-10-01 14:29:21 · 453 阅读 · 0 评论 -
牛客网A-生成树
链接:https://ac.nowcoder.com/acm/contest/223/A来源:牛客网 题目描述你有一张n个点的完全图(即任意两点之间都有无向边)现在给出这张图的两棵生成树定义一次操作为:在任意一棵生成树中删除一条边后再加入一条边(必须在同一棵树中操作),同时需要保证操作完后仍然是一棵树问使得两棵树相同的最少操作次数,若不存在合法的操作方案,输出-1注意:这里...原创 2018-11-05 22:25:58 · 1104 阅读 · 0 评论