码迷,mamicode.com
首页 > 其他好文 > 详细

翻转单词顺序

时间:2017-09-22 17:36:44      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:cout   pen   ace   back   public   name   read   namespace   tor   

#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;

}

 

翻转单词顺序

标签:cout   pen   ace   back   public   name   read   namespace   tor   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!