陆历川

导航

51nod1347 旋转字符串

题目很容易懂,只要进行几次简单的判断就能完成此题,显示判断是否为偶数,之后利用sustr截取两个字符串进行比较,代码如下

#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
string ss;
string a;
string b;
int main()
{
    while(cin>>ss)
   {
       int n=ss.length();
       if(n%2)
       {
           cout<<"NO"<<endl;
       }
       else
       {
          a=ss.substr(n/2,n/2);
          b=ss.substr(0,n/2);
          if(a==b)
            cout<<"YES\n";
          else
            cout<<"NO\n";
       }

   }
    return 0;
}

 

posted on 2017-01-17 13:01  陆历川  阅读(94)  评论(0编辑  收藏  举报