我希望你是我独家记忆

一段永远封存的记忆,随风而去
posts - 263, comments - 31, trackbacks - 0, articles - 3
   :: 首页 :: 新随笔 ::  :: 聚合  :: 管理

HLOJ_1194

Posted on 2009-06-15 13:10 Hero 阅读(71) 评论(0)  编辑 收藏 引用 所属分类: 代码如诗--ACM
 1 //1194  Accepted  0 176 697 C++  
 2 #include <stdio.h>
 3 
 4 int tnum ;
 5 char data[10] ;
 6 
 7 bool isin( int x, int y )
 8 {
 9     if( x >= 1 && x <= 8 && y<=8 && y>=1 )
10         return true ;
11     else
12         return false ;
13 }
14 int main()
15 {
16     while( scanf( "%d"&tnum ) != EOF )
17     {
18         while( tnum -- )
19         {
20             scanf( "%s", data ) ;
21             int x = data[0- 'a' + 1 ;
22             int y = data[1- '1' + 1 ;
23 
24             int cnt = 0 ;
25             if( isin( x+1, y+2 ) ) cnt++ ;
26             if( isin( x-1, y+2 ) ) cnt++ ;
27             if( isin( x+2, y+1 ) ) cnt++ ;
28             if( isin( x-2, y+1 ) ) cnt++ ;
29 
30             if( isin( x+1, y-2 ) ) cnt++ ;
31             if( isin( x-1, y-2 ) ) cnt++ ;
32             if( isin( x+2, y-1 ) ) cnt++ ;
33             if( isin( x-2, y-1 ) ) cnt++ ;
34 
35             printf( "%d\n", cnt ) ;
36         }
37     }
38     return 0 ;
39 }

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理