| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
多点耐心调吧In Reply To:我不行了,谁告诉我哪里WRONG了 Posted by:solo at 2005-04-26 13:39:26 > #include<stdio.h>
> #include<math.h>
>
> int fun(int n, int m, int p, int q){
> if(n==p||m==q||abs(n-p)==abs(m-q))
> return 1;
> else return 0;
> }
>
> void main(){
> int a[10][10], b[3], d[3], i, j, k, l, real, s=10, t=10;
> char c[3];
>
> for(i=1;i<=8;i++){
> for(j=1;j<=8;j++){
> a[i][j]=0;
> }
> }
> scanf(" %c%d %c%d %c%d", &c[0], &b[0], &c[1], &b[1], &c[2], &b[2]);
> for(i=0;i<3;i++) d[i]=c[i]-'a'+1;
> for(i=-1;i<=1;i++){
> for(j=-1;j<=1;j++){
> if(a[d[0]+i][b[0]+j]==0)
> a[d[0]+i][b[0]+j]=1;
> }
> }
> for(i=1;i<=8;i++){
> for(j=1;j<=8;j++){
> real=fun(i, j, d[1], b[1]);
> for(k=-1;k<=1;k++){
> for(l=-1;l<=1;l++){
> //if(k==0&&l==0) continue;
> if(a[d[2]+k][b[2]+l]==0){
> real=real*fun(i, j, d[2]+k, b[2]+l);
> }
> }
> }
> if(real){
> if(i<s) s=i,t=j;
> else if(i==s&&j<t) t=j;//printf("%d %d %d %d\n", i, j, d[2], b[2]);
> }
> }
> }
> if(s==10) printf("no\n");
> else printf("%c%d\n", s+'a'-1, t);
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator