c++
文章平均质量分 66
renjiewen1995
即将毕业成为IT民工
展开
-
[OJ题目]推箱子
[OJ题目]推箱子大家一定玩过“推箱子”这个经典的游戏。具体规则就是在一个N*M的地图上,有1个玩家、1个箱子、1个目的地以及若干障碍,其余是空地。玩家可以往上下左右4个方向移动,但是不能移动出地图或者移动到障碍里去。如果往这个方向移动推到了箱子,箱子也会按这个方向移动一格,当然,箱子也不能被推出地图或推到障碍里。当箱子被推到目的地以后,游戏目标达成。现在告诉你游戏开始是初始的地图布局,请你求...原创 2018-08-21 23:01:09 · 762 阅读 · 0 评论 -
VS2008动态链接库(DLL)的创建与导入
一、创建新的动态链接库(DLL)项目从“File”菜单中,选择“New”,然后选择“Project…”。如下图:在“项目类型”窗格中,选择“Visual C++”下的“Win32”。在“模板”窗格中,选择“Win32 Console Application”。为项目选择一个名称,如 MathFuncsDll,并将其键入“Name:”字段。 为解决方案选择一个名称,如转载 2016-07-20 17:46:43 · 537 阅读 · 0 评论 -
best-time-to-buy-and-sell-stock系列(贪心与动态规划)
一、best-time-to-buy-and-sell-stock题目描述Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one trans原创 2016-09-05 18:46:37 · 1094 阅读 · 0 评论 -
解决01背包问题的DP方法
解题参考:http://blog.csdn.net/wumuzi520/article/details/7014559题目描述: 现有一笔经费可以报销一定额度的发票。允许报销的发票类型包括买图书(A类)、文具(B类)、差旅(C类),要求每张发票的总额不得超过1000元,每张发票上,单项物品的价值不得超过600元。现请你编写程序,在给出的一堆发票中找出可以报销的、不超过给定额度的最原创 2016-09-04 18:44:56 · 864 阅读 · 0 评论 -
辗转相除法证明及复杂度计算
辗转相除法是计算两个数最大公约数(Greatest conmmon divisor)的一种对数复杂度算法。问题:有两个正整数 x , y ,求 gcd(x,y):算法证明:设 x > y , 且 x = r + y * c , 其中 r >= 0, c >= 0 ; 1. if r = 0 then gcd( x,y) == y 为结束条件)2. if c = 0原创 2016-08-30 17:45:54 · 2462 阅读 · 0 评论 -
vs下C++内存泄露检测
参考文章:http://msdn.microsoft.com/zh-cn/library/x98tx3cf.aspx1、在main方法所在的文件里加上如下代码://可以定位到发生内存泄露 所在的文件和具体那一行,用于检测 malloc 分配的内存 2 #define _CRTDBG_MAP_ALLOC 3 #include 4 #include 5转载 2016-08-02 23:58:21 · 397 阅读 · 0 评论 -
用栈实现Fibnacci递归过程的非递归算法
#include#include using namespace std;//模拟递归工作栈。//data表示当前状态的参数值//state表示当前栈的完成状态,state = 2 表示未计算, state = 1 表示计算了递归树左部,state = 0 表示计算了整个递归子树struct stackNode{ int data; int state; stackNode原创 2016-08-04 16:28:45 · 2412 阅读 · 0 评论 -
文件读写: 二进制方式和文本方式的区别
首先要明白一点,就是无论你用哪种语言进行程序设计,也无论你用哪个函数进行文件操作(库函数也好,直接操作系统API也好),最终的文件打开的操作都是由操作系统来进行的,因此各种语言的情况从本质上来说都是相同的。 用二进制模式打开一个文件的时候,文件本身的内容和你编写程序时用函数读到的内容完全相同(或者说和磁盘上的内容完全相同)。 但是如果用了文本模式,那么操作系统在将文件内转载 2016-08-03 23:23:40 · 10447 阅读 · 1 评论 -
C++移位运算符
左移运算符右移运算符代码示例如下: int x = -1; cout<<(unsigned int)x<<endl; cout<< (x<<1) <<endl >1)<<endl <<((unsigned int)x<<1)<<endl >1)原创 2016-07-26 23:15:45 · 332 阅读 · 0 评论 -
VS2008调试技术
1. How to run your program under the control of the Visual C++ 2008 debugger❑ How to step through your program a statement at a time❑ How to monitor or change the values of variables in your progr原创 2016-10-15 15:32:24 · 436 阅读 · 0 评论 -
C++与宏
A macro is not C++ code. It’s a name defined by a #define pre-processor directive that will be replacedby some text that will normally be C++ code, but could also be constants or symbols of some kin原创 2016-10-16 21:10:47 · 252 阅读 · 0 评论 -
3_矩阵变换_《3D图形编程基础——基于DirectX11》笔记
第三章、矩阵变换 本章讲解三维变换的基本知识,了解三维变换的数学表示及其在图形学中的意义。第三章矩阵变换1 基本变换11 平移变换12 旋转变换13 缩放变换2 XNA矩阵变换函数3 几何变换的组合目标:基本矩阵变换:平移、缩放、旋转XNA库中的矩阵变换函数学习几何变换的组合3.1 基本变换 矩阵变换中最为基础的原创 2018-01-26 23:01:02 · 373 阅读 · 0 评论 -
2_矩阵_《3D图形编程基础——基于DirectX11》笔记
二、矩阵 在三维计算机图形学中,使用矩阵描述几何变换,比如平移,旋转,缩放等;通过运算将向量或点从一个空间转换到另一个空间。本章讲解矩阵的概念及其运算。二矩阵1 矩阵的定义2 矩阵的运算21 矩阵相等加减法和数乘22 矩阵乘法23矩阵转置3 单位矩阵4 逆矩阵5 XNA矩阵目标:矩阵的定义矩阵的运算XNA库中矩阵的表示和操作原创 2018-01-25 17:52:48 · 308 阅读 · 0 评论 -
1_向量_《3D图形编程基础——基于DirectX11》笔记
一、向量一向量1 向量的概念11 向量的表示12 左手坐标系与右手坐标系2 向量的长度及标准化21 向量的长度22 向量的标准化3 向量的运算31 加减32 数乘33 点积34 叉积4 齐次坐标系5 XNA向量目标:向量的定义和表示方式。向量的标准化。向量的运算,包括加减、数乘、点乘、叉乘坐标系和齐次坐标系XNA库中向量原创 2018-01-24 21:06:55 · 322 阅读 · 0 评论 -
关于VS2008属性配置几点总结
1、输出目录和中间目录输出目录默认输出到解决方案目录下的debug或release处,是工程的输出结果,供解决方案中的其它项目使用中间目录是当前工程的中间输出结果,仅为当前工程使用;其中宏定义可从下拉菜单中的编辑一项,点击宏查看2、包含目录和附加包含目录附加包含目录:当前工程所包含头文件所在的文件夹,所谓附加,就是在包含目录的基础上附加了这些目录;包含目录:对于在VS中创建的所有工程,包含头文件时...原创 2016-07-20 18:08:15 · 2067 阅读 · 0 评论 -
获取指定目录及其子目录下所有文件的绝对路径
获取指定目录及其子目录下所有文件的绝对路径 这个问题困扰了我很久,听说python和java的OS库很容易解决,而在linux下便更容易了。但我常在windows下用C++,对其他语言不太熟悉。刚开始从网上搜了一段批处理指令,将后缀名改为bat,便可以将所有文件路径重定向到指定的文件中,用起来还挺方便。@echo off & setlocal EnableDelayedExpansionfor原创 2017-03-06 12:26:48 · 3564 阅读 · 1 评论 -
sublime text 3配置c/c++编译环境
本文介绍sublime text 3的c/c++开发环境搭建,包括MinGW的安装,gcc运行c语言,g++运行c++语言,在sublime中运行以及在cmd中运行的方法。另外对于MinGW和gcc,还有sublime的build文件做了简单介绍。sublime text 3提供了构建功能,它的构建系统(Build systems)可以运行一段外部命令,还可以捕获输出并显示。转载 2016-03-20 19:32:46 · 2792 阅读 · 2 评论 -
Ubuntu 中安装低版本的gcc/g++
(2012-06-30 10:47:58)转载▼标签: it分类: Ubuntu发现Android的版本中编译Host的程序经常因为本机的Gcc版本过高,需要这样那样的修改,烦的很!索性直接降级gcc和g++, 而且可以很容易切换ubuntu 12.04 中带的Gcc/G++都是4.6了,我们把系统默认的降转载 2016-11-13 22:37:00 · 2464 阅读 · 0 评论 -
翻译 Dark Channel Prior based Image De-hazing: A Review
(Abstract-Digital images captured under poor environments are vulnerably degraded in their capacities to convey adequate amount of information to the viewer or computer-based processes.One of the comm原创 2016-11-10 19:26:18 · 680 阅读 · 0 评论 -
Leetcode——populating-next-right-pointers-in-each-node
题目描述Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its原创 2016-04-20 21:44:02 · 224 阅读 · 0 评论 -
Leetcode——binary-tree-maximum-path-sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return6.原创 2016-04-20 19:54:04 · 295 阅读 · 0 评论 -
LINUX下文件操作函数
Linux的文件操作API涉及到创建、打开、读写和关闭文件。1.linux API 创建int creat(const char *filename, mode_t mode); 参数mode指定新建文件的存取权限,它同umask一起决定文件的最终权限(mode&umask),其中umask代表了文件在创建时需要去转载 2016-03-20 20:39:31 · 293 阅读 · 0 评论 -
朋友圈转发信息
在一个社交应用中,两个用户设定朋友关系后,则可以互相收到对方发布或转发的信息。当一个用户发布或转发一条信息时,他的所有朋友都能收到该信息。 现给定一组用户,及用户之间的朋友关系。问:当某用户发布一条信息之后,为了让每个人都能在最早时间收到这条信息,这条信息最少需要被转发几次? 假设:对所有用户而言:1)朋友发出信息到自己收到该信息的时延为T(T>0);2)如需转发,从收原创 2016-03-31 21:14:28 · 301 阅读 · 0 评论 -
最大的正方形
最大的正方形描述:给你一个N*M的矩阵,每个位置的值是0或1,求一个面积最大的子矩阵,这个矩阵必须是一个正方形,且里面只能由1构成,输出最大的正方形边长运行时间限制:2 Sec内存限制:无限制输入:第一行输入两个整数n,m,之后n行,每行m个数字,为矩阵第i行第j列的值,只可能是0或者1原创 2016-03-31 18:40:22 · 604 阅读 · 0 评论 -
字符串流 istringstream 和 ostringstream 的用法
字符串流 istringstream 和 ostringstream 的用法iostream 标准库支持内存中的输入/输出,只要将流与存储在程序内存中的 string 对象捆绑起来即可。此时,可使用 iostream 输入和输出操作符读写这个 string 对象。标准库定义了三种类型的字符串流: • istringstream,由 istream 派生而来,提供读 st转载 2016-03-30 19:33:26 · 401 阅读 · 0 评论 -
string C++
标准C++中的string类的用法总结相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用。但是如果离开了MFC框架,还有没有这样使用起来非常方便的类呢?答案是肯定的。也许有人会说,即使不用MFC框架,也可以想办法使用MFC中的API,具体的操作方法在本文最后给出操作方法。其实,可能很多人很可能会忽略掉标准C+转载 2016-03-30 19:26:08 · 262 阅读 · 0 评论 -
Vector查找
vector::iterator result = find( cnt[temp].begin( ),cnt[temp].end( ), Word ); if ( result == cnt[temp].end( ) ){ //没找到cnt[temp].push_back(Word);return true;}else {//找到return false;}原创 2016-03-05 22:57:14 · 216 阅读 · 0 评论 -
大整数(可怕的阶乘)
题目标题:· 计算阶乘n!是一件可怕的事情,因为当n并不是很大时,n!将是一个很大的值。例如13! = 6227020800,已经超过了我们常用的unsigned int类型的取值范围。请设计一个程序,使其可以计算100以内的数的阶乘,结果用字符串的形式输出详细描述:· 接口说明原型:void CalcNN(int n, char *pOut)输原创 2016-03-05 11:58:40 · 347 阅读 · 0 评论 -
删除重复字符(4737)
删除重复字符给定一个字符串,将字符串中所有和前面重复多余的字符删除,其余字符保留,输出处理后的字符串。需要保证字符出现的先后顺序,并且区分大小写。详细描述:接口说明原型:int GetResult(const char *input, char *output)输入参数: input 输入的字符串原创 2016-03-04 19:55:00 · 259 阅读 · 0 评论 -
STL中set使用
1.关于setC++ STL 之所以得到广泛的赞誉,也被很多人使用,不只是提供了像vector, string, list等方便的容器,更重要的是STL封装了许多复杂的数据结构算法和大量常用数据结构操作。vector封装数组,list封装了链表,map和set封装了二叉树等,在封装这些数据结构的时候,STL按照程序员的使用习惯,以成员函数方式提供的常用操作,如:插入、排序、删除、查找等。让转载 2016-03-04 19:27:12 · 329 阅读 · 0 评论 -
HD1142 穿越丛林
A Walk Through the ForestTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7221 Accepted Submission(s): 2640Problem DescriptionJimm原创 2016-04-02 15:32:20 · 487 阅读 · 0 评论 -
ACM常用的C++头文件!
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #includ转载 2016-04-03 17:13:13 · 795 阅读 · 0 评论 -
Leetcode—— trapping-rain-water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given[0,1,0,2,1,0,1,3,2,1,2,1],原创 2016-04-19 21:23:44 · 279 阅读 · 0 评论 -
leetcode----最长有效括号字串
题目描述Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest valid parentheses substring i原创 2016-04-19 20:34:53 · 2437 阅读 · 0 评论 -
leetcode——largestRectangleArea
题目描述Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram原创 2016-04-19 19:35:15 · 344 阅读 · 0 评论 -
leetcode——链表reorder
#include using namespace std; struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; class Solution {public: void reorderList(ListNode *hea原创 2016-04-18 23:33:53 · 224 阅读 · 0 评论 -
leetcode——已序链表合并
#include using namespace std; struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; class Solution {public: ListNode* mergeTwoLists(ListNo转载 2016-04-18 20:09:32 · 200 阅读 · 0 评论 -
leetcode——链表快排
#include using namespace std; struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; class Solution {public: void swapp ( int & x,int原创 2016-04-18 20:44:38 · 732 阅读 · 0 评论 -
leetCode——随机链表复制
#include using namespace std;//Definition for singly-linked list with a random pointer.struct RandomListNode { int label; RandomListNode *next, *random; RandomListNode(int x) : label(x), next(NU原创 2016-04-18 19:54:21 · 400 阅读 · 0 评论 -
成都麻将
#include#include#include #include using namespace std;class cmp{public:cmp();bool operator()( string x,string y){if( x[1] == y[1] ){return x[0]}elsereturn c[ x[1] ]原创 2016-03-26 23:10:15 · 453 阅读 · 0 评论