UVA 401


//Notes:  1、每个结果最后有2个\n\n  2、‘A‘->‘A‘ ‘B‘->‘ ‘  ‘E‘->‘3‘    3、0与O要一样
#include <iostream>
using namespace std;
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
string str0 = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
string str1 = "_A   3  HIL JM O   2TUVWXY51SE Z  8 0";
//»ØÎÄpalindrome
bool isPalindromeString(string str){
    for(int i = 0, len = str.length(); i <= len/2; i++)
        if(str[i] != str[len-i-1]) return 0;
    return 1;
}
bool isMirroedString(string str){
    for(int i = 0, len = str.length(); i <= len/2; i++){
        if((str[i] == ‘0‘ && str[len-1-i]==‘O‘) || (str[i] == ‘O‘ && str[len-i-1]==‘0‘)) continue;
        else if(str1[str0.find(str[i])] != str[len-i-1]) return 0;
    }
    return 1;
}
int main(){
    //freopen("data.in", "r", stdin);
    string string;
    while(cin >> string){
        if(isMirroedString(string)){
           if(isPalindromeString(string)) cout << string << " -- is a mirrored palindrome.";
           else  cout << string << " -- is a mirrored string.";
        }else{
            if(isPalindromeString(string)) cout << string << " -- is a regular palindrome.";
            else cout << string << " -- is not a palindrome.";
        }
        cout << "\n\n";
    }
    return 0;
}

  

时间: 2024-10-10 18:29:59

UVA 401的相关文章

UVa 401 Palindromes(字符串,回文)

 Palindromes  A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the same when the string is read from left to right as when the string i

UVA 401 Palindromes(回文词)

 回文词 Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVA 401 Appoint description:  acmparand  (2013-07-07)Luke  (2014-01-20) System Crawler  (2015-05-10) Description A regular palindrome is a string of

UVa 401 Palindromes(简单字符串)

简单的判断是否是回文串.镜像串,然后自己写的真费劲,没逃掉刘汝佳的书,这里的代码很有技巧性,特别值得学习,额,其实他书上的代码都很精简 Character Reverse Character Reverse Character Reverse A A M M Y Y B   N   Z 5 C   O O 1 1 D   P   2 S E 3 Q   3 E F   R   4   G   S 2 5 Z H H T T 6   I I U U 7   J L V V 8 8 K   W W

uva 401.Palindromes

题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=342 题目意思:给出一段字符串(大写字母+数字组成).判断是否为回文串 or 镜像串 or 回文镜像串 or 什么都不是.每个字母的镜像表格如下 Character Reverse Character Reverse Character Reverse A A M M Y Y B

UVa 401 Palindromes(镜像回文字符串)

 题意  给一个字符串 判定其是否为回文串和镜像串  回文串很好判断  镜像串对于每一个字符用数组保存它的镜像字符就行了  没有的就是空格 注意若字符串长度为奇数  中间那个字母必须是对称的才是镜像串 #include<cstdio> #include<cctype> #include<cstring> const int N = 35; int l; char s[N], mc[] = "A 3 HIL JM O 2TUVWXY5", mn[]

回文词(Palindromes, UVa 401)

输入一个字符串,判断它是否为回文串以及镜像串.输入字符串保证不含数字0.所谓回文串,就是反转以后与原串相同,如abba和madam.所谓镜像串,就是左右镜像之后和原串相同,如2S和3AIAE.注意,并不是每个字符在镜像之后都能得到一个合法字符.(空白项表示该字符镜像后不能得到一个合法字符.) Character Reverse Character Reverse Character Reverse A A M M Y Y B N Z 5 C O O 1 1 D P 2 S E 3 Q 3 E F

UVa 401 回文词

背景:1WA__for循环限制条件不正确,应该是把最中间那个词也判断一下.2WA__list表建立错误,在T之前多了一个空格.3WA--ans内单词拼写错误!! 学习:1.对于输出复杂,建表复杂的题要格外小心,什么拼写错误之类的别犯!! 2. const char* ans[]={"is not a palindrome.","is a regular palindrome.","is a mirrored string.","is a

【鬼畜】UVA - 401每日一题&#183;猛男就是要暴力打表

管他什么rev数组,msg数组简化代码 #define _CRT_SECURE_NO_WARNINGS #include <cmath> #include <iostream> #include <stdio.h> #include<algorithm> #include <map> #include <cstring> #include <time.h> #include <string> using nam

Palindromes UVA - 401

题意参见紫书 #include<bits/stdc++.h> using namespace std; #define me(s) memset(s,0,sizeof(s)) #define _for(i,a,b) for(int i=(a);i<(b);++i) #define _rep(i,a,b) for(int i=(a);i<=(b);++i) #define mp make_pair #define pb push_back #define all(x) (x).beg