自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 win10+opencv4.01+opencv_contrib+vs2017编译过程

intuition虽然写的是win10+opencv4.01+opencv_contrib的编译过程,但各个系统各个版本大同小异,都可以作为参考。下面是编译过程。第一步,准备工作首先安装cmake,下载地址在这:https://cmake.org/download/,之后去github下载opencv和对应版本的opencv_contrib,opencv下载地址:https://github...

2019-10-20 22:02:16 607 1

原创 1004. 成绩排名 (20)

读入n名学生的姓名、学号、成绩,分别输出成绩最高和成绩最低学生的姓名和学号。输入格式:每个测试输入包含1个测试用例,格式为第1行:正整数n 第2行:第1个学生的姓名 学号 成绩 第3行:第2个学生的姓名 学号 成绩 … … … 第n+1行:第n个学生的姓名 学号 成绩 其中姓名和学号均为不超过10个字符的字符串,成绩为0到100之间的一个整数,这里保证在一组测试用例中没有两

2018-01-21 19:53:17 298

原创 1003. 我要通过!(20)

“答案正确”是自动判题系统给出的最令人欢喜的回复。本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”。得到“答案正确”的条件是:字符串中必须仅有P, A, T这三种字符,不可以包含其它字符;任意形如 xPATx 的字符串都可以获得“答案正确”,其中 x 或者是空字符串,或者是仅由字母 A 组成的字符串;如果 aPbTc 是正确的

2018-01-21 19:52:08 342

原创 1002. 写出这个数 (20)

读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字。输入格式:每个测试输入包含1个测试用例,即给出自然数n的值。这里保证n小于10^100。输出格式:在一行内输出n的各位数字之和的每一位,拼音数字间有1 空格,但一行中最后一个拼音数字后没有空格。输入样例: 1234567890987654321123456789 输出样例: yi san wu#include<iostream

2018-01-21 19:50:34 328

原创 1001. 害死人不偿命的(3n+1)猜想 (15)

卡拉兹(Callatz)猜想:对任何一个自然数n,如果它是偶数,那么把它砍掉一半;如果它是奇数,那么把(3n+1)砍掉一半。这样一直反复砍下去,最后一定在某一步得到n=1。卡拉兹在1950年的世界数学家大会上公布了这个猜想,传说当时耶鲁大学师生齐动员,拼命想证明这个貌似很傻很天真的命题,结果闹得学生们无心学业,一心只证(3n+1),以至于有人说这是一个阴谋,卡拉兹是在蓄意延缓美国数学界教学与科研的进

2018-01-21 19:48:46 242

原创 A+B problem

leetcode 开始收费了,开始转战lintcode。Write a function that add two numbers A and B. You should not use + or any arithmetic operators. ClarificationAre a and b both 32-bit integers?Yes.Can I use bit

2018-01-19 10:52:32 336

原创 141. Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?判断一个链表是否有环。条件是能否用O(1)的空间复杂度解决这个问题。既然不让我们用多余的空间,那么我们首先想到的是遍历这个链表,我们维持两个指针,一个快,一个慢,如果有环的

2018-01-18 23:38:09 192

原创 122. Best Time to Buy and Sell Stock II

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one

2018-01-18 23:16:21 179

原创 113. Path Sum II

Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.For example: Given the below binary tree and sum = 22,return 给一个二叉树和一个数字sum,让你找出所有路径和为su

2018-01-18 22:46:35 279

原创 110. Balanced Binary Tree

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ

2018-01-18 22:22:16 180

原创 Binary Tree Level Order Traversal

Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).For example: Given binary tree [3,9,20,null,null,15,

2018-01-18 21:49:56 232

原创 Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the

2018-01-18 15:26:37 185

原创 <T110>Balanced Binary Tree

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ

2018-01-18 14:38:09 177

原创 Path Sum

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example: Given the below binary tree and sum

2018-01-18 13:21:32 167

原创 <T111> Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.这道题的目的就是求二叉树的最小高度. 和求二叉树高度不同的是,它需要判断每

2018-01-18 13:04:00 210

原创 <T121>Best Time To Buy And Sell Stack I

say you have an array for witch the i th element is the price of a given stock on day i. if you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2018-01-17 12:49:45 287

原创 <T125>Valid Palindrome

Given a string, determine if it is a palindrome. considering only alphanumeric characters and ignoring cases.Notes: Have you consider the string might be empty?class Solution{ bool isPalind

2018-01-16 21:32:51 211

原创 Single Number

Given an array of integers, every element appears twice except for one. find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra

2018-01-16 13:04:53 171

原创 Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the fastest leaf node. /*struct TreeNode{ int val;

2018-01-16 00:01:42 166

原创 Symmetric Tree

Given a binary tree, check whether it is a mirror of itself. For example, the binary tree[1,2,2,3,4,4,3] is a symmetric tree. Notes bonus points if you could solve it both recursively and iterat

2018-01-15 23:53:35 179

原创 python实现矩阵乘法

最近刚开始学习python,为啥要学习这门语言呢?因为学校做项目的需要(>^http://pymbook.readthedocs.io/en/latest/index.html 这个博客入门的。最近刚学完list,就写了这个矩阵乘法入手。光看不练假把式。编程就是要多动手啊。n = int(input("enter rows of matrix A:"))a = []for i in ra

2018-01-04 13:48:18 1210

原创 二叉树的实现以及递归遍历的精确模拟

对于一个二叉树,我们来精确模拟他的递归遍历过程后序递归遍历的代码如下:void posttravel(BinTree t){ if(!t){ posttravel(t->left); posttravel(t->right); printf("%c "t->data); }}我们知道,递归遍历要借助堆栈,并且前序、中序

2017-11-26 12:27:35 379

原创 C/C++中如何计算程序运行时间?

C/C++中有个计时函数clock(), 它对应的数据类型是clock_t, clock_t clock(void);他返回从程序进程开始到遇到clock()cpu所用的计时单元(clock tick)个数,clock_t是长整型的, 在头文件time.h中,有个常量CLOCKS_PER_SEC,表示一秒钟有多少个这样的CPU计时单元,计时单元的单位是1毫秒,不能更精确。

2017-11-10 21:27:09 721

翻译 我对KMP算法的理解

我对KMP算法的理解翻译自: jBoxer's blog    原文链接: http://jakeboxer.com/blog/2009/12/13/the-knuth-morris-pratt-algorithm-in-my-own-words/    在过去的几天,我读了好几篇关于“利用KMP算法查找字符串的解释”的文章。出于某些原因,没有一篇是能令我接受和理解的。每当

2017-10-30 12:27:26 406

原创 由中序和后序(前序)序列求前序(后序)序列

已知二叉树的中序和后序(前序)序列可以唯一确定一颗二叉树,例如,中序序列:1 2 3 4 5 6后序序列:3 4 2 6 5 1可以唯一确定一颗二叉树,如下图:思路是这样的:    我们知道对于一颗二叉树,根节点是后序遍历序列的最后一个,找到根节点后,我们由中序遍历的特点知道,中序序列中,根节点 左边的是左子树,右边的是右子树。之后分别在左子树、右子树中运用

2017-10-26 23:00:53 6147 4

原创 <PTA> Lists Leaves

Given a tree, you are supposed to list all the leaves in the order of top down, and left to right.Input Specification:Each input file contains one test case. For each case, the first line gives a

2017-10-24 20:18:47 232

原创 <PTA>树的同构

给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。图一图二现给定两棵树,请你判断它们是否是同构的。输入格式:输入给出2棵二叉树树的信息。对于每棵树,首先在一行中给出一个非负整数N

2017-10-24 18:55:50 384

原创 <PTA>Reversing Linked List

Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→

2017-10-21 18:26:04 526

原创 <PTA>数列求和-加强版

7-38 数列求和-加强版(20 分)给定某数字A(1≤A≤9)以及非负整数N(0≤N≤100000),求数列之和S=A+AA+AAA+⋯+AA⋯A(N个A)。例如A=1,N=3时,S=1+11+111=123。输入格式:输入数字A与非负整数N。输出格式:输出其N项数列之和S的值。输入样例:1 3输出样例:123 解题思路:题目的

2017-10-20 22:24:17 5961

原创 Arrays.sort()如何实现从大到小排序

Java中的Arrays.sort()方法默认将数组元素从大到小排序. 要实现从大到小排序java也提供了一种方法:Arrays中的sort(T[] a, Comparator c), 但是传入的数组类型不能是基本类型(int char double),只能使用对应的类(Integer),因为Comparator接口中的compare()方法默认从小到大排序,我们只需要重写这个方法就行

2017-10-08 21:16:54 27161 2

原创 plusone

/*2017.10.8LeedCode:plusone开始学c++了*/class Solution {public: vector plusOne(vector& digits) { vector ret(digits.size(), 0); int one = 1; for(int i = digits.size()-1; i

2017-10-08 10:05:38 256

原创 Remove Duplicates from Sorted Array II

/*2017.10.7//LeedCode : Remove Duplicates from Sorted Array II 需要一个计数器,如果重复次数小于2,就把这个元素放到新数组里.*/int removeDuplicates(int* nums, int numsSize) { int k = 0, i, cnt = 1;; if(numsSize ==

2017-10-07 17:07:46 198

原创 RemoveDuplicates form Sort Array

/*2017.10.7LeetCode : RemoveDuplicates form Sort Array*/int removeDuplicates(int* nums, int numsSize) { int k = 0, i; if (numsSize == 0) return numsSize; for(i = 1; i < nu

2017-10-07 16:47:20 266

原创 Remove Element

/*2017.10.7LeetCode : Remove Element 把数组中和val相等的值覆盖掉就行了.*/int removeElement(int* nums, int numsSize, int val) { int i, k = 0; for(i = 0; i < numsSize; i++){ if(nums[i] != val

2017-10-07 16:29:11 238

原创 Add Two Numbers

今天开始刷LeedCode了.发现智商不够用了.有些解题方法是Goole来的...答题语言都是c语言,顺便也是巩固了一下数据结构原题链接:点击打开链接/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }

2017-10-07 15:46:21 181

原创 <ACM>求多边形重心和面积问题

描述在某个多边形上,取n个点,这n个点顺序给出,按照给出顺序将相邻的点用直线连接, (第一个和最后一个连接),所有线段不和其他线段相交,但是可以重合,可得到一个多边形或一条线段或一个多边形和一个线段的连接后的图形; 如果是一条线段,我们定义面积为0,重心坐标为(0,0).现在求给出的点集组成的图形的面积和重心横纵坐标的和;输入第一行有一个整数0每组数据第一行有一个整

2017-09-26 23:01:15 1185

原创 <PTA>一元多项式的求和和乘积运算解题报告

这是PTA的一道练习题,题目如下:设计函数分别求两个一元多项式的乘积与和。输入格式:输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式:输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。

2017-09-25 22:59:18 1205

原创 Pop Sequence

这是PAT上的一道题,用c++简单些,因为要用到堆栈(stack), 我用c语言写了个, 如果有简单的思路, 希望大家提示#include#include#define MAX 1000int a[MAX];typedef struct SNode{ int *m; int top;} *Stack;void Push(Stack PtrS, int x);void Po

2017-09-14 11:46:11 396 1

原创 最大子序列和问题

问题描述:给定一组有i个整数的序列,要求找出加和最大的一段连续子序列,打印出加和和子序列起始和终止元素,如果这个序列元素都为负数,则打印序列的其实和终止元素。题目来源:https://pintia.cn/problem-sets/900290821590183936/problems/900291257604861953以下是代码片段:// 9.12 宁夏大学#include

2017-09-12 07:34:52 2035

原创 java实现简单计算器

java实现简单计算器功能:简单计算器:两数运算,平方,加负号,实现了复制粘贴功能 * 参考资料:《Java编程思想》、JDK1.6、 CSDN博客:http://blog.csdn.net/baidu_38132719/article/details/69221053?locationNum=4&fps=1 * 2017.5.4于宁夏大学下面是源代码,由于初学Java,许多东

2017-05-08 22:38:50 575

空空如也

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

TA关注的人

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