Cracking The Coding Interview 1.2
//原文:
//
// Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.)
//
// 从前向后交换,到中间为止 #include <iostream>
using namespace std;
void mSwap(char &a, char &b)
{
char c=a;
a=b;
b=c;
}
void mReverse(char *str)
{
if (str == NULL)
{
return;
}
int size = strlen(str);
for (int i =0;i< size/2; i++)
{
mSwap(str[i], str[size-1-i]);
}
}
int main()
{
char s[] = "abcdefg";
cout << s <<endl;
mReverse(s);
cout << s <<endl;
return 0;
}
Cracking The Coding Interview 1.2的更多相关文章
- Cracking the coding interview
写在开头 最近忙于论文的开题等工作,还有阿里的实习笔试,被虐的还行,说还行是因为自己的水平或者说是自己准备的还没有达到他们所需要人才的水平,所以就想找一本面试的书<Cracking the co ...
- Cracking the coding interview 第一章问题及解答
Cracking the coding interview 第一章问题及解答 不管是不是要挪地方,面试题具有很好的联系代码总用,参加新工作的半年里,做的大多是探索性的工作,反而代码写得少了,不高兴,最 ...
- Cracking the Coding Interview(Trees and Graphs)
Cracking the Coding Interview(Trees and Graphs) 树和图的训练平时相对很少,还是要加强训练一些树和图的基础算法.自己对树节点的设计应该不是很合理,多多少少 ...
- Cracking the Coding Interview(Stacks and Queues)
Cracking the Coding Interview(Stacks and Queues) 1.Describe how you could use a single array to impl ...
- 《Cracking the Coding Interview》读书笔记
<Cracking the Coding Interview>是适合硅谷技术面试的一本面试指南,因为题目分类清晰,风格比较靠谱,所以广受推崇. 以下是我的读书笔记,基本都是每章的课后习题解 ...
- Cracking the coding interview目录及资料收集
前言 <Cracking the coding interview>是一本被许多人极力推荐的程序员面试书籍, 详情可见:http://www.careercup.com/book. 第六版 ...
- 《Cracking the Coding Interview》——第13章:C和C++——题目6
2014-04-25 20:07 题目:为什么基类的析构函数必须声明为虚函数? 解法:不是必须,而是应该,这是种规范.对于基类中执行的一些动态资源分配,如果基类的析构函数不是虚函数,那么 派生类的析构 ...
- 《Cracking the Coding Interview》——第5章:位操作——题目7
2014-03-19 06:27 题目:有一个数组里包含了0~n中除了某个整数m之外的所有整数,你要设法找出这个m.限制条件为每次你只能用O(1)的时间访问第i个元素的第j位二进制位. 解法:0~n的 ...
- 二刷Cracking the Coding Interview(CC150第五版)
第18章---高度难题 1,-------另类加法.实现加法. 另类加法 参与人数:327时间限制:3秒空间限制:32768K 算法知识视频讲解 题目描述 请编写一个函数,将两个数字相加.不得使用+或 ...
- 《Cracking the Coding Interview 》之 二叉树的创建 与 遍历(非递归+递归version)
#include <iostream> #include <cstdio> #include <vector> #include <stack> #de ...
随机推荐
- python requests库与json数据处理详解
1. http://docs.python-requests.org/zh_CN/latest/user/quickstart.html get方法将参数放在url里面,安全性不高,但是效率高:pos ...
- 在python中使用正则表达式(二)
这一节主要学习一下compile()函数和group()方法 1. re.compile() compile 函数用于编译正则表达式,生成一个正则表达式( Pattern )对象,然后就可以用编译后 ...
- C#调用EXE
1.问题意义 据说界面程序开发,首选C#(像lebview之类的也很好) 但是,能不能用其他语言开发核心代码,只用C#做界面?毕竟每种语言都有自己擅长的领域. 2.exe程序 比如有个example. ...
- 线性代数 | Linear Algebra
网上说<线性代数应该这样学>非常不错,再配合大学教材,把线性代数的基本知识点过一遍. 线性代数 - 知乎 最近在跟一个教程:李宏毅的线性代数 基本知识: Rn :We denote the ...
- English trip V1 - B 13. Are you a model? 你是模特吗? Teacher:Patrick Key: 单词回顾、词性后缀
因为这节课本身内容过于So easy~ Patrick给我补充了很多课外内容 课上内容(Lesson) I doesn't work 2层意思 1) 东西坏了,这个东西不能正常工作了.比如钟不走时间 ...
- pip安装kolla-ansible时报错Cannot install 'PyYAML'的解决方法
pip install kolla-ansible --ignore-installed PyYAML
- Activiti搭建
Activiti搭建 前期准备: JDK+Eclipse+Tomcat+Maven的安装与配置 参考:http://blog.csdn.net/zhshulin/article/details/307 ...
- link标签实现给网页标题前加一个小图标favicon.ico
使用方法如下:1.<link rel="shortcut icon " type="images/x-icon" href="./favicon ...
- WEB环境相关技术、配置
一.简介(基本概念) web开发中基本概念和用到的技术: A — AJAX AJAX 全称为“ Asynchronous JavaScript and XML ”(异步 JavaScript 和 XM ...
- ubuntu计划任务的编写
1,首先,我编写的计划任务是在ubunut系统上的.首先我们来认识一下每一个 * 这样子的符号代表什么意思吧! * * * * * 从左到右: 第1列表示分钟1-59 每分钟用*或者 */1表 ...