首页 > 其他 > 详细

51nod1347 旋转字符串

时间:2017-01-17 13:56:26      阅读:195      评论:0      收藏:0      [点我收藏+]

题目很容易懂,只要进行几次简单的判断就能完成此题,显示判断是否为偶数,之后利用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;
}

 

51nod1347 旋转字符串

原文:http://www.cnblogs.com/lulichuan/p/6292612.html

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