首页 > 其他 > 详细

翻转单词顺序

时间:2017-09-22 17:00:56      阅读:231      评论:0      收藏:0      [点我收藏+]
#include<stdio.h>
#include<string.h>
#include <pthread.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <stdlib.h>
#include <sstream>
using namespace std;


class Solution
{
public:
    string LeftRotateString(string str, int n)
    {
        int length=str.length();
        cout<<length<<endl;
        if(n>length)
            return str;
        else
        {
            string front=str.substr(0,n);
            string back=str.substr(n);
            back.append(front);
            return back;
        }
    }
};

int main()
{

    Solution s;
    string str="XYZabdfg";
    cout<<s.LeftRotateString(str,10)<<endl;
    system("pause");
    return 0;

}

 

翻转单词顺序

原文:http://www.cnblogs.com/bananaa/p/7575582.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!