zoukankan      html  css  js  c++  java
  • 2029 回文串问题

    水~~不过有些小问题

    这是AC代码:

    #include<iostream>
    #include<string.h>
    using namespace std;
    int main()
    {
        int n,y;
        char s[500];
        while(cin>>n)
        while(n--)
     {
           scanf("%s",s);
        y=1;
           int k=strlen(s);
           for(int i=0;i<=k/2;i++)
        {
               if(s[i]!=s[k-i-1])
               y=0;
        }
        cout<<(y?"yes":"no")<<endl;
     }
        return 0;
    }

    当加了个break后就过不了了。。。

    #include<iostream>
    #include<string.h>
    using namespace std;
    int main()
    {
        int n,y;
        char s[500];
        while(cin>>n)
        while(n--)
     {
           scanf("%s",s);
        y=1;
           int k=strlen(s);
           for(int i=0;i<=k/2;i++)
        {
               if(s[i]!=s[k-i-1])
               y=0;

               break;
        }
        cout<<(y?"yes":"no")<<endl;
     }
        return 0;
    }

  • 相关阅读:
    Linux文件结构
    磁盘分区
    BASH简介
    磁盘的基本概念
    Linux文件操作
    创建文件系统
    文件系统挂载
    一些常用命令
    asp.net创建PPT
    asp.net创建、删除、移动文件夹 文件
  • 原文地址:https://www.cnblogs.com/bersaty/p/2110953.html
Copyright © 2011-2022 走看看