zoukankan      html  css  js  c++  java
  • poj1590

    简单题

    View Code
    #include <iostream>
    #include
    <cstdio>
    #include
    <cstdlib>
    #include
    <cstring>
    using namespace std;

    #define maxn 50

    int n;
    char st[maxn];
    char match[1000];
    bool p, m;

    bool isp()
    {
    for (int i = 0; i < n / 2; i++)
    if (st[i] != st[n - i - 1])
    return false;
    return true;
    }

    bool ism()
    {
    for (int i = 0; i < n / 2 + 1; i++)
    if (st[i] != match[st[n - i - 1]])
    return false;
    return true;
    }

    int main()
    {
    //freopen("t.txt", "r", stdin);
    memset(match, -1, sizeof(match));
    match[
    'A'] = 'A';
    match[
    'E'] = '3';
    match[
    'H'] = 'H';
    match[
    'I'] = 'I';
    match[
    'J'] = 'L';
    match[
    'L'] = 'J';
    match[
    'M'] = 'M';
    match[
    'O'] = 'O';
    match[
    'S'] = '2';
    match[
    'T'] = 'T';
    match[
    'U'] = 'U';
    match[
    'V'] = 'V';
    match[
    'W'] = 'W';
    match[
    'X'] = 'X';
    match[
    'Y'] = 'Y';
    match[
    'Z'] = '5';
    match[
    '1'] = '1';
    match[
    '2'] = 'S';
    match[
    '3'] = 'E';
    match[
    '5'] = 'Z';
    match[
    '8'] = '8';
    while (scanf("%s", st) != EOF)
    {
    n
    = strlen(st);
    p
    = isp();
    m
    = ism();
    printf(
    "%s", st);
    if (!p && !m)
    printf(
    " -- is not a palindrome.\n");
    else if (p && !m)
    printf(
    " -- is a regular palindrome.\n");
    else if (!p && m)
    printf(
    " -- is a mirrored string.\n");
    else
    printf(
    " -- is a mirrored palindrome.\n");
    putchar(
    '\n');
    }
    return 0;
    }

  • 相关阅读:
    正则表达式基础学习
    二识angularJS
    元素的居中方式总结
    初识AngularJs
    初识Vue.js
    Flight学习(一)
    Servlet/JSP-07 Session应用
    Servlet/JSP-05 Cookie
    Servlet/JSP-06 Session
    Servlet/JSP-04 JSP基础
  • 原文地址:https://www.cnblogs.com/rainydays/p/2100009.html
Copyright © 2011-2022 走看看