码迷,mamicode.com
首页 >  
搜索关键字:reverse nodes    ( 8673个结果
使用迭代器逆置容器元素
代码如下: template void reverse(It begin, It end) { while(begin != end) { --end; if(begin != end) std::swap(*begin++, *end); } } 注意几点: 1.不能一开始...
分类:其他好文   时间:2014-09-28 21:37:45    阅读次数:232
线性表之静态链表
#include#include #include"windows.h"using namespace std;struct StaticLinkNode{ int data; int next;};struct StaticLink{ StaticLinkNode* nodes;...
分类:其他好文   时间:2014-09-28 16:13:23    阅读次数:135
leetcode - Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. Y...
分类:其他好文   时间:2014-09-28 14:33:56    阅读次数:178
字符串移位
字符串循环移位:假设有一串字符串a,b,c,d,e,f,g,h,向左循环移位2为,得c,d,e,f,g,h,a,b。 #include using namespace std; void reverse(char* a, int start, int len){ int count = 0; for(int i = start, j = start + len -1; ; ++i, --...
分类:其他好文   时间:2014-09-28 12:28:20    阅读次数:140
Evaluate Reverse Polish Notation
题目描述:Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another ex...
分类:其他好文   时间:2014-09-28 11:27:51    阅读次数:164
leetcode Evaluate Reverse Polish Notation
#include#include#include#include#include#include#includeusingnamespacestd;intevalRPN(vector&tokens){stackvalue;inti=0;for(i=0;is;s.push_back("4");s.pu...
分类:其他好文   时间:2014-09-28 00:52:20    阅读次数:209
leetcode Reverse Words in a String
#include#include#include#includeusingnamespacestd;voidreverseWords(string&s){stringrs;for(inti=s.length()-1;i>=0;){while(s[i]==''&&i>=0)i--;if(i=0)t.p...
分类:其他好文   时间:2014-09-28 00:14:40    阅读次数:220
HDU Tree LCA 2014 ACM/ICPC Asia Regional Shanghai Online
题意: 给定n个点的树,m个操作 树有点权和边权 下面n-1行给出树边 下面m行操作 : ● ADD1 u v k: for nodes on the path from u to v, the value of these nodes increase by k. ● ADD2 u v k: for edges on the path from u to v, the value...
分类:其他好文   时间:2014-09-27 20:30:00    阅读次数:202
leetcode - Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are labeled uniquely. We use # as a separator for ea...
分类:其他好文   时间:2014-09-27 15:16:19    阅读次数:121
利用逆波兰(Reverse Polish Notation, RPN)的后缀表达法计算四则运算表达式
如果是单纯的加减运算表达式,非常简单,依次处理表达式的头字符就可以了。但是对于四则运算来说,有括号,又有先乘除,后加减使得表达式处理变得负责。20世纪50年代,波兰逻辑学家Jan Lukasiewicz发明了不需要括号的后缀表达式,精妙地解决的这个问题。比如说char sInput[]="9+(3-...
分类:其他好文   时间:2014-09-27 12:23:59    阅读次数:200
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!