//原文:
//
// 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的更多相关文章

  1. Cracking the coding interview

    写在开头 最近忙于论文的开题等工作,还有阿里的实习笔试,被虐的还行,说还行是因为自己的水平或者说是自己准备的还没有达到他们所需要人才的水平,所以就想找一本面试的书<Cracking the co ...

  2. Cracking the coding interview 第一章问题及解答

    Cracking the coding interview 第一章问题及解答 不管是不是要挪地方,面试题具有很好的联系代码总用,参加新工作的半年里,做的大多是探索性的工作,反而代码写得少了,不高兴,最 ...

  3. Cracking the Coding Interview(Trees and Graphs)

    Cracking the Coding Interview(Trees and Graphs) 树和图的训练平时相对很少,还是要加强训练一些树和图的基础算法.自己对树节点的设计应该不是很合理,多多少少 ...

  4. 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 ...

  5. 《Cracking the Coding Interview》读书笔记

    <Cracking the Coding Interview>是适合硅谷技术面试的一本面试指南,因为题目分类清晰,风格比较靠谱,所以广受推崇. 以下是我的读书笔记,基本都是每章的课后习题解 ...

  6. Cracking the coding interview目录及资料收集

    前言 <Cracking the coding interview>是一本被许多人极力推荐的程序员面试书籍, 详情可见:http://www.careercup.com/book. 第六版 ...

  7. 《Cracking the Coding Interview》——第13章:C和C++——题目6

    2014-04-25 20:07 题目:为什么基类的析构函数必须声明为虚函数? 解法:不是必须,而是应该,这是种规范.对于基类中执行的一些动态资源分配,如果基类的析构函数不是虚函数,那么 派生类的析构 ...

  8. 《Cracking the Coding Interview》——第5章:位操作——题目7

    2014-03-19 06:27 题目:有一个数组里包含了0~n中除了某个整数m之外的所有整数,你要设法找出这个m.限制条件为每次你只能用O(1)的时间访问第i个元素的第j位二进制位. 解法:0~n的 ...

  9. 二刷Cracking the Coding Interview(CC150第五版)

    第18章---高度难题 1,-------另类加法.实现加法. 另类加法 参与人数:327时间限制:3秒空间限制:32768K 算法知识视频讲解 题目描述 请编写一个函数,将两个数字相加.不得使用+或 ...

  10. 《Cracking the Coding Interview 》之 二叉树的创建 与 遍历(非递归+递归version)

    #include <iostream> #include <cstdio> #include <vector> #include <stack> #de ...

随机推荐

  1. Ubuntu更改源和搜狗输入法安装卸载

    安装完Ubuntu 16.04后,要更换为国内的软件源: sudo gedit /etc/apt/sources.list   #用文本编辑器打开源列表 在文件开头添加下面的阿里云的软件源: deb ...

  2. causal snps | causal variants | tensorflow | 神经网络实战 | Data Simulation

    先读几篇文章: Interpretation of Association Signals and Identification of Causal Variants from Genome-wide ...

  3. 20165303 魏煜第四次实验 Android开发

    实验内容 1实验要求: 参考<Java和Android开发学习指南(第二版)(EPUBIT,Java for Android 2nd)>第二十四章: 参考http://www.cnblog ...

  4. 使用visual studio把xsd文件转成xml格式文件

    使用visual studio把xsd文件转成xml格式文件 最近一段时间都在做Amazon的mws api的对接工作,mws api的描述文件都是使用的xsd文件来进行的,之前确实也没有接触过,也花 ...

  5. WPF——动画

    本文目录 前言 1.线性插值动画 2.关键帧动画 3.路径动画 前言 使用动画,是增强用户体验的一种有效的手段.合理的动画,可以让应用程序的界面看起来更加自然.真实.流畅.舒适,更有效地向用户展现信息 ...

  6. patch-test-and-proc

    实验环境 Ubuntu 14.04.5 LTS Linux - 4.15.6 为单个文件进程补丁操作 在桌面 Desktop 建立文件夹 patch ,作为实验用,然后进入patch 文件夹.建立测试 ...

  7. 1. windows 下redis数据库的安装

    安装 window系统的redis是微软团队根据官方的linux版本高仿的 官方原版: https://redis.io/ 中文官网:http://www.redis.cn 下载地址: https:/ ...

  8. Elsevier系旗下期刊论文投稿流程

    目录 1.上传文件需求 2.注册账号和填写相关信息 3.以作者身份登入 4.开始提交论文:点击submit New Manuscript 5.选择论文类型:一般是科技长文Full Length Art ...

  9. apache2反向代理

    1.安装 Apache2 sudo apt-get install apache2 2.重启服务器 sudo /etc/init.d/apache2 restart 3.虚拟主机配置 启用这几个模块 ...

  10. Leetcode 131

    class Solution { public: vector<vector<string>> partition(string s) { vector<string&g ...