左旋转字符串

 


#include "stdafx.h"
#include "string"
using namespace std;

class MyClass
{
public:
    MyClass();
    ~MyClass();
    string leftRoteStr(string str, int patern)
    {
        int strLen = str.size();

        if (strLen == 0 || patern == 0)
        {
            return "";
        }
        string strSrc = str;
        string strTemp = "";
        string strReturn = "";
        strTemp = str.erase(patern , strLen);
        strReturn = strSrc + strTemp;

        strReturn = strReturn.erase(0, patern - 1);
        return strReturn;
    }

private:

};

MyClass::MyClass()
{
}

MyClass::~MyClass()
{
}

int main()
{
    MyClass my_class;
    string strRet;
    strRet=my_class.leftRoteStr("abcdef", 2);
    return 0?strRet.size() > 0:1;
}

posted on 2020-04-14 23:05  心中日月007  阅读(91)  评论(0编辑  收藏  举报