用C或C++实现void reverse( char* str )函数,即反转一个null结尾的字符串。分析:先确定字符串的长度,然后从两端往中间遍历,同时交换两端的元素。 1 #include 2 #include 3 #include 4 5 using namespace std; 6...
分类:
其他好文 时间:
2014-09-14 20:31:47
阅读次数:
209
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321Have you thought about this?Here are some good questions to ask...
分类:
其他好文 时间:
2014-09-13 20:05:05
阅读次数:
189
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ...
分类:
其他好文 时间:
2014-09-13 20:00:35
阅读次数:
207
定义链表结构struct ListNode{ int val; ListNode *next; ListNode(int v) : val(v), next(NULL) {}};非递归反转单链表ListNode* reverse(ListNode *root){ if (ro...
分类:
其他好文 时间:
2014-09-12 23:21:44
阅读次数:
235
最近复习考研,加上一直都将"算法"放在很高的位置,所以,蛮重视算法的.不多说了,其实这个问题,不难理解的.主要代码: 1 //反转单链表. 2 void 3 reverse(linklist lList) { 4 Linknode *pre = NULL; //注意该结点不能再指向别的...
分类:
其他好文 时间:
2014-09-12 01:11:24
阅读次数:
221
仅提供个人的一种解题思路,未必是最优,仅供各位参考!
import java.util.Stack;
/**
*
*
* ClassName SolutionEvaluateReversePolishNotation
*
*
* Description 该题是解逆波兰表达式 Evaluate the value of an arithmetic expression i...
分类:
其他好文 时间:
2014-09-11 22:29:42
阅读次数:
257
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321 1 public class Solution { 2 public int reverse(int x) { 3 ...
分类:
其他好文 时间:
2014-09-11 20:48:02
阅读次数:
223
Problem 1:vector coll = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };vector::const_iterator pos = find (coll.cbegin(), coll.cend(),5);cout ::const_reverse_iterator r...
分类:
其他好文 时间:
2014-09-11 18:56:12
阅读次数:
226
仅提供个人的一种解题思路,未必是最优,仅供各位参考!...
分类:
其他好文 时间:
2014-09-11 17:18:52
阅读次数:
180