401 - Palindromes
来源:互联网 发布:产品进入淘宝首页 编辑:程序博客网 时间:2024/06/09 22:40
#include<stdio.h>
#include<string.h>
char table[2][21]=
{
'A','E','H','I','J','L','M','O','S','T','U','V','W','X','Y','Z','1','2','3','5','8',
'A','3','H','I','L','J','M','O','2','T','U','V','W','X','Y','5','1','S','E','Z','8'
};
char mirror(char c)
{
int i;
for(i=0;i<21;i++)
{
if(table[0][i]==c) returntable[1][i];
if(table[1][i]==c) returntable[0][i];
}
return ' ';
}
int issame(char c)
{
int i;
for(i=0;i<21;i++)
if(table[0][i]==c&& table[1][i]==c) return1;
return 0;
}
int main()
{
int n,i,ispal,ismir;
char input[25];
while (scanf("%s",input)==1)
{
ispal=ismir=1;
n=strlen(input);
for(i=0;i<n/2;i++)
{
if(input[i]!=input[n-1-i])ispal=0;
if(input[i]!=mirror(input[n-1-i]))ismir=0;
}
if(n%2==1&& !issame(input[n/2]))ismir=0;
if(ispal==0&& ismir==0) printf("%s -- is not apalindrome.\n",input);
if(ispal==1&& ismir==0) printf("%s -- is aregular palindrome.\n",input);
if(ispal==0&& ismir==1) printf("%s -- is amirrored string.\n",input);
if(ispal==1&& ismir==1) printf("%s -- is amirrored palindrome.\n",input);
printf("\n");
}
return 0;
}
uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=342
0 0
- 401 Palindromes
- 401 - Palindromes
- 401 - Palindromes
- 401 - Palindromes
- 401 - Palindromes
- 401 - Palindromes
- 401 - Palindromes
- 401 - Palindromes
- 401 - Palindromes
- 401 - Palindromes
- UVa 401 Palindromes
- UVaOJ 401 Palindromes
- UVa OJ 401-Palindromes
- UVa:401 - Palindromes
- uva 401 Palindromes //字符串
- uva 401 - Palindromes
- UVa 401 - Palindromes
- UvaOj 401 - Palindromes
- 489 - Hangman Judge
- 694 - The Collatz Sequence
- C# ASP.NET GridView导出EXCEL。
- Linux Input子系统--设备的注册和打开
- 457 - Linear Cellular Automata
- 401 - Palindromes
- 10010 - Where's Waldorf?
- 10361 - Automatic Poetry
- 《jQuery基础教程》4th 笔记- 选择元素
- 537 - Artificial Intelligence?
- 409 - Excuses, Excuses!
- 10878 - Decode the tape
- 10815 - Andy's First Dictionary
- 644 - Immediate Decodability