HDOJ2029 Palindromes _easy version 回文数

Post Code:

#include<iostream>
using namespace std;

int main(){
    int n,p,q;
    bool test;
    char str[100];
    scanf("%d",&n);
    getchar();
    while(n--){
    test=true;
    gets(str);
    for(p=0,q=strlen(str)-1;p<=q;p++,q--){
          if(str[p]!=str[q]){
              test=false;
              break;
              }
              }
          if(test)
              printf("yes\n");
          else
              printf("no\n");
              }
        return 0;
    }



你可能感兴趣的:(杭电oj)