标签:CM namespace 输出 \n 代码 rom php 字符 ble
http://acm.hdu.edu.cn/showproblem.php?pid=2029
zzt 的代码:
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; char s[maxn]; int main() { int n; while(~scanf("%d", &n)) { for(int i = 1; i <= n; i ++) { scanf("%s", s); int ans = 1; int len = strlen(s); for(int j = 0; j < len / 2; j ++) { if(s[j] != s[len - j - 1]) ans = 0; } if(ans) printf("yes\n"); else printf("no\n"); } } return 0; }
小张的代码:
#include <bits/stdc++.h> using namespace std; int a[111],b[111]; char s[100]; int flag,flag1; int main() { int n; cin>>n; for(int i=1; i<=n; i++) { while(scanf("%s",s)!=EOF) { int len = strlen(s); if(len%2==0) { for(int i=0; i<len/2; i++) { if(s[i]==s[len-1-i]) flag=1; else flag=0; } if(flag==1) cout<<"yes"<<endl; else cout<<"no"<<endl; } else { for(int i=0; i<(len-1)/2; i++) { if(s[i]==s[len-1-i]) flag1=1; else flag1=0; } if(flag1==1) cout<<"yes"<<endl; else cout<<"no"<<endl; } } return 0; } }
HDU 2029 Palindromes _easy version
标签:CM namespace 输出 \n 代码 rom php 字符 ble
原文地址:https://www.cnblogs.com/zlrrrr/p/9226225.html