| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2527 人关注过本帖
标题:C++里如果忽略大小写问题
只看楼主 加入收藏
ciappcia
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-6-7
收藏
得分:0 
#include <iostream>
#include <cstring>
using namespace std;

bool isPalindrome(const char *);

int main() {
    char i='a',j='A';
    cout<<(int)i<<(int)j;
    cout << "Enter a string:";
    char s[80];
    cin.getline(s, 80);
    if(isPalindrome(s))
        cout << s << " is a palindrome" << endl;
    else
        cout << s << " is not a palindrome" << endl;
    
    return 0;
}

bool isPalindrome(const char * const s)
{
    int low = 0;
    int high = strlen(s) - 1;
    
    while (low < high)
    {
        if (s[low] != s[high]&&(s[low]+32!=s[high])&&(s[low]-32!=s[high]))
            return false;
        low++;
        high--;
    }
    
    return true;
}
2008-11-08 19:37
快速回复:C++里如果忽略大小写问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014184 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved