自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(235)
  • 收藏
  • 关注

原创 QT之文本编辑器实现

1.mainwindow.h[cpp] view plain copy #ifndef MAINWINDOW_H  #define MAINWINDOW_H    #include   #include   #include     namespace Ui {  class MainWindow;  }  

2016-11-08 16:51:43 999 1

原创 QT之文本编辑器实现

1.mainwindow.h#ifndef MAINWINDOW_H#define MAINWINDOW_H#include #include #include namespace Ui {class MainWindow;}class MainWindow : public QMainWindow{ Q_OBJECTpublic: explicit

2016-11-07 10:01:59 2129 2

原创 Remote monitoring software

一、功能描述:受控端功能描述:1)尽可能隐蔽的方式在后台运行。2)能够接受控制端的指令并返回相应的操作结果。3)一个受控端能够同时被多个控制端控制。控制端功能描述:1)能够自动发现局域网中的所有受控端。2)能够获取指定受控端的桌面截图。3)能够在受控端执行任意命令并返回结果。4)能够向指定受控端发送可执行文件并执行。5)一个控制端能够同时控制多个受控端。

2016-10-14 12:31:17 431

原创 awk总结

awk是一个非常棒的数据处理工具,相比于sed常常作用于一整行的处理,awk则比较倾向于将一行分成数个“字段”来处理。因此,awk相当适合于处理小型的数据处理。下面是我写的测试脚本:#!/bin/sh#测试awk的通用模式#awk '条件类型1{动作1} 条件类型2{动作2} ...' filenameecho -e "\n测试awk的通用模式!" #必须加上转义-e,否则无法换

2016-04-20 10:17:38 349

原创 leetcode 89:Gray Code

题目:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the seque

2015-12-07 18:49:46 241

原创 数学上的一些算法

1.求两个数的最大公约数可以使用辗转相除法,实现简单,效率高。int gcd(int a, int b){ while (b != 0) { int t = a%b; a = b; b = t; } return a;}假设r是a,b的最大公约数,则有(a,b)=(b,r),这就是原理。2.求素数(质数)的算法第一种暴力解法,时间复杂度:O(n^

2015-12-04 21:30:20 365

原创 typedef用法

1.常规变量类型定义例如:typedef unsigned char uchar描述:uchar等价于unsigned char类型定义 uchar c声明等于unsigned char c声明2.数组类型定义例如: typedef int array[2];描述: array等价于 int [2]定义; array a声明等价于int a[2]声明扩展: ty

2015-12-04 19:16:18 221

原创 leetcode 88:Merge Sorted Array

题目:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to hol

2015-12-02 23:02:20 412

原创 条款49中关于new-handler行为

当operator new无法满足某一内存分配时,就会抛出一次。以前它会返回NULL指针,现在某些旧式编译器也还这么做。 namespace std{ typedef void(*new_handler)(); new_handler set_new_handler(new_handler p) throw(); }new_handler是个函数

2015-12-02 21:55:02 400

原创 条款48提及的模板元编程

模板元编程(TMP)是编写template-based C++程序并执行与编译期的过程。TMP有两个伟大的效力。第一,它让某些事情更容易。第二,由于template metaprograms执行于C++编译期,因此可将工作从运行期转移到编译期。TMP没有真正的循环条件,所以循环效果由递归完成。下面是一个例子:#include using namespace std;//

2015-12-02 21:04:29 300

原创 条款24与条款46:关于类型转换与non-member函数

条款24:若所有参数皆需类型转换,请为此采用non-member函数通常情况,class不应该支持隐式类型转换,因为这样可能导致我们想不到的问题。这个规则也有例外,最常见的例外是建立数值类型时。例如编写一个有理数管理类,允许整数隐式类型转换为有理数似乎颇为合理。class Rational{ public: Rational(int numerator=0, int den

2015-12-02 16:42:52 304

原创 leetcode 87:Scramble String

题目:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great /

2015-12-02 14:13:13 428

原创 leetcode 86:Partition List

题目:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes i

2015-12-02 13:02:38 346

原创 leetcode 83:Remove Duplicates from Sorted List

题目:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.思路:这题很简单,直接上代码

2015-11-30 21:00:02 262

原创 leetcode 82:Remove Duplicates from Sorted List II

题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Gi

2015-11-30 20:49:33 272

原创 leetcode 81:Search in Rotated Sorted Array II

题目:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target

2015-11-29 20:41:42 329

原创 leetcode 80:Remove Duplicates from Sorted Array II

题目:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the f

2015-11-29 15:56:25 252

原创 leetcode 79:Word Search(redo)

题目:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or v

2015-11-29 13:20:27 257

原创 leetcode 78:Subsets

题目:Given a set of distinct integers, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.

2015-11-27 23:08:28 258

原创 leetcode 77:Combinations

题目:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3],

2015-11-27 22:45:32 259

原创 leetcode 76:Minimum Window Substring

题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum windo

2015-11-26 22:39:31 283

原创 leetcode 75:Sort Colors

题目:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the

2015-11-26 21:38:32 213

原创 leetcode 74:Search a 2D Matrix

题目:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first intege

2015-11-26 20:57:08 338

原创 leetcode 72:Edit Distance

题目:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitt

2015-11-24 20:18:27 203

原创 leetcode 70:Climbing Stairs

题目:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?思路:这题和前面Unique Path

2015-11-24 19:06:19 220

原创 leetcode 69:

题目:Implement int sqrt(int x).Compute and return the square root of x.思路:用二分法,比较简单时间复杂度:O(lgn)class Solution {public: int sqrt(int x) { if (0 == x) return 0;

2015-11-23 19:29:04 250

原创 list::swap函数

void swap (list& x);Swap contentExchanges the content of the container by the content of x, which is another list of the same type. Sizes may differ.After the call to this member function,

2015-11-20 20:45:55 1565

原创 copy函数

元素复制算法copy。该算法主要用于容器之间元素的拷贝,即将迭代器区间[first,last)的元素复制到由复制目 标result给定的区间[result,result+(last-first))中。下面我们来看看它的函数原型: template OutputIterator copy( InputIterator _First,

2015-11-20 10:24:28 914

原创 leetcode 66:Add Binary

题目:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".string addBinary(string a, string b) { string result = ""; i

2015-11-19 22:00:57 398

原创 leetcode 65:Plus One

题目:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.思路:这题比较简单

2015-11-19 21:33:54 257

原创 leetcode 63:Unique Paths II

题目:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively

2015-11-19 20:56:09 243

原创 leetcode 62:Unique Paths

题目:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to rea

2015-11-19 20:32:10 224

原创 leetcode 61:Rotate List

题目:Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.思路:这题可以先确定链表数,然后找到需要截断的结

2015-11-19 19:47:11 227

原创 leetcode 60:Permutation Sequence

题目:The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213"

2015-11-18 21:33:23 281

原创 leetcode 59:Spiral Matrix II

题目:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9

2015-11-18 21:15:57 282

原创 leetcode 58:Length of Last Word

题目:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A

2015-11-18 20:49:43 246

原创 leetcode 57:Insert Interval

题目:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start ti

2015-11-18 20:31:36 384

原创 leetcode 56:Merge Intervals

题目:Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].struct Interval { int start; int end; In

2015-11-18 19:27:35 264

原创 Expression : invalid operator <

今天用sort来对vector进行排序,然后排序函数如下: static bool comp(const Interval a, const Interval b) { return a.start > b.start ? 1 : (a.start < b.start ? -1 : 0); }结果一直提示错误。后来查了下,大概是出这个错是因为VS2005,VS2008后的sor

2015-11-18 19:03:34 296

原创 仿函数与临时对象

仿函数(functor),就是使一个类的使用看上去象一个函数。其实现就是类中实现一个operator(),这个类就有了类似函数的行为,就是一个仿函数类了。所谓临时变量,就是一种无名对象。有的时候可以制造一些临时对象,可以使程序干净清爽。可以制造临时对象的方法是,在类别名称之后直接加一对小括号,并可指定初值,其意义相当于调用相应的constructor且不指定对象名称。STL最常将此技巧应用于仿

2015-11-18 13:11:41 444

空空如也

空空如也

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

TA关注的人

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