Easy-8

来源:互联网 发布:淘宝电商需要什么条件 编辑:程序博客网 时间:2024/05/29 15:40

leetcode   344. Reverse String           

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

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


AC:

char* reverseString(char* s) {
    int length=strlen(s);
   
    for(int i=0;i<length/2;i++)
    {
        int k=s[i];
        s[i]=s[length-1-i];
        s[length-1-i]=k;
    }
    return s;
}

0 0
原创粉丝点击