Reverse String

Write a function that takes a string as input and returns the string reversed.

Example:
Given s = "hello", return "olleh".

  1. /*************************************************************************
  2. > File Name: LeetCode344.c
  3. > Author: Juntaran
  4. > Mail: Jacinthmail@gmail.com
  5. > Created Time: 2016年05月10日 星期二 02时25分37秒
  6. ************************************************************************/
  7.  
  8. /*************************************************************************
  9.  
  10. Reverse String
  11.  
  12. Write a function that takes a string as input and returns the string reversed.
  13.  
  14. Example:
  15. Given s = "hello", return "olleh".
  16.  
  17. ************************************************************************/
  18.  
  19. #include "stdio.h"
  20.  
  21. char* reverseString(char* s)
  22. {
  23. int i;
  24. int length = strlen(s);
  25. char temp;
  26.  
  27. for( i=; i<length/; i++ )
  28. {
  29. temp = s[i];
  30. s[i] = s[length-i-];
  31. s[length-i-] = temp;
  32. }
  33. return s;
  34. }
  35.  
  36. int main()
  37. {
  38. char* s = "hello";
  39. reverseString(s);
  40. return ;
  41. }

LeetCode 344的更多相关文章

  1. LeetCode 344. Reverse String(反转字符串)

    题目描述 LeetCode 344. 反转字符串 请编写一个函数,其功能是将输入的字符串反转过来. 示例 输入: s = "hello" 返回: "olleh" ...

  2. Leetcode 344:Reverse String 反转字符串(python、java)

    Leetcode 344:Reverse String 反转字符串 公众号:爱写bug Write a function that reverses a string. The input strin ...

  3. 前端与算法 leetcode 344. 反转字符串

    目录 # 前端与算法 leetcode 344. 反转字符串 题目描述 概要 提示 解析 解法一:双指针 解法二:递归 算法 传入测试用例的运行结果 执行结果 GitHub仓库 # 前端与算法 lee ...

  4. [LeetCode] 344 Reverse String && 541 Reverse String II

    原题地址: 344 Reverse String: https://leetcode.com/problems/reverse-string/description/ 541 Reverse Stri ...

  5. [LeetCode] 344. Reverse String 翻转字符串

    Write a function that reverses a string. The input string is given as an array of characters char[]. ...

  6. Leetcode#344. Reverse String(反转字符串)

    题目描述 编写一个函数,其作用是将输入的字符串反转过来. 示例 1: 输入: "hello" 输出: "olleh" 示例 2: 输入: "A man ...

  7. leetcode 344. Reverse String 、541. Reverse String II 、796. Rotate String

    344. Reverse String 最基础的旋转字符串 class Solution { public: void reverseString(vector<char>& s) ...

  8. Leetcode 344. 反转字符串

    344. Reverse String 解题代码: class Solution { public: void reverseString(vector<char>& s) { , ...

  9. Java实现 LeetCode 344 反转字符串

    344. 反转字符串 编写一个函数,其作用是将输入的字符串反转过来.输入字符串以字符数组 char[] 的形式给出. 不要给另外的数组分配额外的空间,你必须原地修改输入数组.使用 O(1) 的额外空间 ...

  10. LeetCode 344. Reverse String

    Problem: Write a function that takes a string as input and returns the string reversed. Example: Giv ...

随机推荐

  1. 【转】linux代码段,数据段,BSS段, 堆,栈

    转载自 http://blog.csdn.net/wudebao5220150/article/details/12947445  linux代码段,数据段,BSS段, 堆,栈 网上摘抄了一些,自己组 ...

  2. Android实例-读取设备联系人(XE8+小米2)

    相关资料: http://www.colabug.com/thread-1071065-1-1.html 结果: 1.将权限打开Read contacts设置为True,不然报图一的错误. 2.搜索空 ...

  3. iOS 使用FMDB SQLCipher给数据库加密

    关于SQLite,SQLCipher和FMDB SQLite是一个轻量的.跨平台的.开源的数据库引擎,它的在读写效率.消耗总量.延迟时间和整体简单性上具有的优越性,使其成为移动平台数据库的最佳解决方案 ...

  4. ucGUI例程收藏

    ucGUI 几个重要例程Demo   按钮的定制 #include <stddef.h> #include <string.h> #include "WM.h&quo ...

  5. Python 3.2: 使用pymysql连接Mysql

    在python 3.2 中连接MYSQL的方式有很多种,例如使用mysqldb,pymysql.本文主要介绍使用Pymysql连接MYSQL的步骤 1        安装pymysql ·       ...

  6. c# 实现IComparable、IComparer接口、Comparer类的详解

    在默认情况下,对象的Equals(object o)方法(基类Object提供),是比较两个对象变量是否引用同一对象.我们要必须我自己的对象,必须自己定义对象比较方式.IComparable和ICom ...

  7. apache 限制IP网段访问

    <Directory "地址.."> Options Indexes FollowSymLinks MultiViews AllowOverride None Orde ...

  8. PIL在windwos系统下Image.show无法显示图片问题的解决方法

    环境:1.win7 64位 2.python 2.7.8 3.PIL-1.1.7.win32-py2.7 在运行一下例子时候出现问题: #-*-coding:utf-8-*- __author__ = ...

  9. Android——设计原则(Design Principles)

    Enchant Me Delight me in surprising ways(动画.音效...) Real objects are more fun than buttons and menus( ...

  10. 我所经历的SAP选型

    这是一个失败的选型项目,而且在可遇见的未来公司也不会再经历SAP选型,甚至不会再启动erp项目,个中原因很难一言道尽,在此简要的说说我们的选型过程以及在选型过程中对各种因素的考虑. 一.重启选型工作七 ...