poj 2993 Emag eht htiw Em Pleh

来源:互联网 发布:lolvsdota 知乎 编辑:程序博客网 时间:2024/05/18 02:16

2996的逆换,输入输出,输出输入,相同的方法,需要观察下.和:的变化情况。

#include<cstdio>#include<cstring>#include<iostream>#define N 101using namespace std;int map[10][10];char str1[N],str2[N];int main(){    gets(str1);    gets(str2);    int len1,len2;    len1 = strlen(str1);    len2 = strlen(str2);    memset(map,0,sizeof(map));    for(int i=0;i<len1;++i)    {      if('0'<=str1[i]&&str1[i]<='9')      {          if(str1[i-2]==',')          {           map[str1[i]-'0'][str1[i-1]-'a'+1]='P';          }          else          {           map[str1[i]-'0'][str1[i-1]-'a'+1]=str1[i-2];          }      }    }     for(int i=0;i<len2;++i)    {      if('0'<=str2[i]&&str2[i]<='9')      {          if(str2[i-2]==',')          {           map[str2[i]-'0'][str2[i-1]-'a'+1]='p';          }          else          {           map[str2[i]-'0'][str2[i-1]-'a'+1]=str2[i-2]+'a'-'A';          }      }    }    bool flag=false;    printf("+---+---+---+---+---+---+---+---+\n");    for(int i=8;i>=1;--i)    {    printf("|");    if(flag)    {       for(int j=1;j<=8;++j)       {         if(j%2==0)         {            if(map[i][j]==0)            {              printf("...|");            }            else            {                printf(".%c.|",map[i][j]);            }         }         else         {             if(map[i][j]==0)            {              printf(":::|");            }            else            {                printf(":%c:|",map[i][j]);            }         }       }    }    else    {       for(int j=1;j<=8;++j)       {         if(j%2==0)         {             if(map[i][j]==0)            {              printf(":::|");            }            else            {                printf(":%c:|",map[i][j]);            }         }         else         {            if(map[i][j]==0)            {              printf("...|");            }            else            {                printf(".%c.|",map[i][j]);            }         }       }    }    flag = !flag;    cout<<endl;    printf("+---+---+---+---+---+---+---+---+\n");    }    return 0;}


原创粉丝点击