回文字符串的测试
2011-09-08 10:37
211 查看
#include <iostream> using namespace std; void test_int_circle(const int a) { int num = a; int b[10]; int i = 0; int begin, end; int temp; while (num) { temp = num % 10; b[i] = temp; i++; num = num / 10; } begin = 0; end = i - 1; while(begin < end) { if (b[begin] == b[end]) { begin++; end--; } else { break; } } if (begin < end) { printf("false\n"); } else { printf("true\n"); } } void test_char_circle(const char a[], const int length) { int begin = 0, end = length -1; while(a[begin] != NULL && begin < end) { if (a[begin] == a[end]) { begin++; end--; } else { break; } } if (begin < end) { cout<<"false"<<endl; } else { cout<<"true"<<endl; } } int main() { /*int a; cout<<"please input the number of you:"<<endl; cin>>a; test_circle(a); /*char a[]={"aaaaaaa"}; cout<<"please input 3 char:"<<endl; char a[4]; scanf("%s",a); test_char_circle(a,sizeof(a)-1); printf("%s\n",a); return 0; }
直接上代码
相关文章推荐
- 【全排列】亚马逊在线测试-找下一个回文字符串
- 测试一个c风格字符串是否是回文字符串
- 回文字符串的变形——poj1159
- 寻找字符串中最长回文——Manacher算法及其Java实现
- valid-palindrome——判断带符号数字字母的字符串是否为回文
- Java字符串拼接效率测试
- oj:回文字符串处理
- ny 37 回文字符串(LCS)
- leetcode 409. Longest Palindrome 可以构造的最长的回文字符串
- 求一个字符串中的最大回文子串
- Manacher's ALGORITHM: O(n)时间求字符串的最长回文子串 [转载]
- Java 输出字符串 测试
- 最长回文字符串模板(manacher算法 时间复杂度O(n))
- 字符串回文与镜像
- nyoj--37--回文字符串(动态规划)
- 判断组成回文的字符串序列
- 51nod 1092 回文字符串(区间dp)
- Fibonacci数列、判断回文字符串
- 33:判断字符串是否为回文
- Java实现从文本中查找最长的回文字符串