例:输入 “I Love you”,输出“you Love I”;在不使用库函数,不使用sizeof()的情况下:
#include
#include
void reverse_str(char *p,int len) //定义一个反转函数
{
char *left = p;
char *right = p + len-1;
while (left <rig...
分类:
其他好文 时间:
2016-05-13 15:14:50
阅读次数:
181
Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Given s = "hello", return "holle". Example 2:Given s ...
分类:
编程语言 时间:
2016-05-13 08:30:04
阅读次数:
197
Write a function that takes a string as input and returns the string reversed. Example:Given s = "hello", return "olleh". 个人博客:http://www.cnblogs.com/ ...
分类:
编程语言 时间:
2016-05-13 08:04:23
阅读次数:
124
要求大家按照课件中的方式定义链表数据结构,链表的成员函数自己定义,有哪些功能也自己定义,但是必须有如下两个函数:
返回链表中最小的元素:Type SeqList::Get_Min();//使用非递归方式
将链表中元素逆置:List::reverse();//使用递归和非递归两种方式,非递归方式只允许常数单位个额外空间
设计主函数,主函数中能够对所作函数进行测试,并且能够将链表中最小值找到,将链表...
分类:
其他好文 时间:
2016-05-13 03:10:43
阅读次数:
118
题目分析:对于给定的字符串,执行逆转操作。
解题思路:先统计字符串的长度,然后遍历字符串,将字符串的前后元素一一对调即可实现。
实现程序C++版本class Solution {
public:
// 字符交换操作
void my_swap(char *s, char *t)
{
char temp = *s;
*s = *t;...
分类:
其他好文 时间:
2016-05-13 00:36:41
阅读次数:
140
1、Add Two Numbers——这是leedcode的第二题:
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 digit. Add the two num...
分类:
其他好文 时间:
2016-05-13 00:02:34
阅读次数:
394
题目:Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the...
分类:
其他好文 时间:
2016-05-12 23:57:12
阅读次数:
213
题目:输入一个链表的头节点,从头到尾反过来打印出每个节点的值
Reverse()函数:输入头结点,可输出的确是从尾到头;即第一个输入的节点,最后一个输出;最后一个输入的结点,第一个输出;很典型的“后进先出“;用桟实现;
1、将结点放进桟中,当结点全遍历一遍时,链表已经反过来,
2、此时再从桟顶逐个输出结点的值
Reverse2()函数:递归本质就是桟结构;则用_Reverse2(_...
分类:
其他好文 时间:
2016-05-12 18:40:26
阅读次数:
128
题目:按k个结点一组来反转链表
思路:
运用反转链表的通法reverse,对链表进行循环,当计数长度k不时,指针继续前进;当计数长度到达k时,将该组首尾节点first和node作为参数传入翻转函数reverse进行翻转,然后重新拼接到原链表中。直至到达链表末尾。
代码如下:
/**
* Definition for singly-linked list.
* publi...
分类:
其他好文 时间:
2016-05-12 15:46:34
阅读次数:
172
Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Have you thought about this? Here are some good questions t ...
分类:
其他好文 时间:
2016-05-12 06:53:28
阅读次数:
147