zoukankan      html  css  js  c++  java
  • POJ 2993Emag eht htiw Em Pleh

    http://poj.org/problem?id=2993

    这个题与POJ2996正好反着,但个人认为,比2996好做多了,那些边边框框都挺容易输出的,剩下的注意p别忘了给输进去就行,还有白色的是大写,黑色的是小写;

      1 #include<cstdio>
      2 #include<cstring>
      3 #include<iostream>
      4 #include<cstdlib>
      5 #include<algorithm>
      6 using namespace std ;
      7 struct node
      8 {
      9     int row,col;//
     10     char ch ;
     11 }sh[168];
     12 char s1[1006];
     13 int cnt;
     14 char z,w,x,y,u;
     15 int i,j,k,flag;
     16 int cmp(struct node a,struct node b)
     17 {
     18     if(a.row > b.row)
     19         return 1;
     20     else if(a.row == b.row&&a.col < b.col)
     21         return 1;
     22     return 0;
     23 }
     24 void coutt()
     25 {
     26     cin>>s1;
     27     //scanf("%c",&z);
     28     getchar();
     29     while(scanf("%c",&z)&&z != '')
     30     {
     31         if(z < 96&&z != ',')
     32         {
     33             scanf("%c %c",&y,&x);
     34             cnt++;
     35             sh[cnt].ch = z ;
     36             sh[cnt].col = y-96 ;
     37             sh[cnt].row = x-48 ;
     38         }
     39         else if(z != ',')
     40         {
     41             scanf("%c",&w);
     42             cnt++;
     43             sh[cnt].ch = 'P';
     44             sh[cnt].col = z-96 ;
     45             sh[cnt].row = w-48 ;
     46         }
     47     }
     48 }
     49 void couttt()
     50 {
     51     cin>>s1;
     52     //scanf("%c",&z);
     53     getchar();
     54     while(scanf("%c",&z)&&z != '')
     55     {
     56         if(z < 96&&z != ',')
     57         {
     58             scanf("%c %c",&y,&x);
     59             cnt++;
     60             sh[cnt].ch = z ;
     61             sh[cnt].col = y-96 ;
     62             sh[cnt].row = x-48 ;
     63         }
     64         else if(z != ',')
     65         {
     66             scanf("%c",&w);
     67             cnt++;
     68             sh[cnt].ch = 'p';
     69             sh[cnt].col = z-96 ;
     70             sh[cnt].row = w-48 ;
     71         }
     72     }
     73 }
     74 int ju(int i,int j)
     75 {
     76     if((i+j)%2 == 0)
     77         return 0 ;
     78     else return 1;
     79 }
     80 int main()
     81 {
     82     cnt = 0;
     83     /*coutt();
     84     couttt();*/
     85     cin>>s1;
     86     //scanf("%c",&z);
     87     getchar();
     88     while(scanf("%c",&z)&&(z != '
    '))
     89     {
     90         if(z<97 && z!=',')
     91         {
     92             scanf("%c%c",&y,&x);
     93             cnt++;
     94             sh[cnt].ch = z ;
     95             sh[cnt].col = y-96 ;
     96             sh[cnt].row = x-48 ;
     97         }
     98         else if(z != ',')
     99         {
    100             scanf("%c",&w);
    101             cnt++;
    102             sh[cnt].ch = 'P';
    103             sh[cnt].col = z-96 ;
    104             sh[cnt].row = w-48 ;
    105         }
    106     }
    107     cin>>s1;
    108     scanf("%c",&z);
    109     while(scanf("%c",&z)&& z!='
    ')
    110     {
    111         if(z<97 && z!=',')
    112         {
    113             scanf("%c%c",&y,&x);
    114             cnt++;
    115             sh[cnt].ch = z +32;
    116             sh[cnt].col = y-96 ;
    117             sh[cnt].row = x-48 ;
    118         }
    119         else if(z != ',')
    120         {
    121             scanf("%c",&w);
    122             cnt++;
    123             sh[cnt].ch = 'p';
    124             sh[cnt].col = z-96 ;
    125             sh[cnt].row = w-48 ;
    126         }
    127     }
    128     sort(sh+1,sh+cnt+1,cmp);
    129     int k = 1;
    130     printf("+---+---+---+---+---+---+---+---+
    ");
    131     for(i = 1 ; i <= 8 ; i++)
    132     {
    133         for(j = 1 ; j <= 8 ; j++)
    134         {
    135             int flag = ju(i,j);
    136             printf("|");
    137             if(flag) printf(":");
    138             else printf(".");
    139             if(sh[k].col == j&&sh[k].row ==9-i)
    140             {
    141                 printf("%c",sh[k++].ch);
    142             }
    143             else if(flag)
    144                 printf(":");
    145             else
    146                 printf(".");
    147             if(flag) printf(":");
    148             else printf(".");
    149         }
    150         printf("|
    +---+---+---+---+---+---+---+---+
    ");
    151     }
    152     return 0;
    153 }
    View Code
  • 相关阅读:
    理解Golang包导入
    go语言执行windows下命令行的方法
    Go中使用动态库C/C++库
    MongoDB · 引擎特性 · MongoDB索引原理
    Linux中more和less命令用法
    修改Linux文件句柄限制
    MongoDB自动删除过期数据--TTL索引
    mongodb可以通过profile来监控数据 (mongodb性能优化)
    MongoDB学习笔记(索引)
    查看nginx cache命中率
  • 原文地址:https://www.cnblogs.com/luyingfeng/p/3246537.html
Copyright © 2011-2022 走看看