-
#include <stdio.h>
-
#include <string.h>
-
-
int main()
-
{
-
int n = 8, i = 0, flag = 0, j = 0, z = 0, ans = 1, count;
-
char? str[35], search[2][7]={"KQRBNP","kqrbnp"}, *p, col, chess[8][35];
-
-
while(n--)
-
{
-
scanf("%s%s", str,str); //连续读两次,把边界+---+row丢掉
-
strcpy(chess+n, str); //逆row存储
-
}
-
-
printf("White: ");
-
-
while(1)
-
{
-
while(i < 6)
-
{
-
count = 0;
-
n = z;
-
-
while(n = z + count * ans, count < 8)
-
{
-
if(p = (char*)memchr(chess[n], search[j][i], strlen(chess[n])))
-
{
-
if(flag) //第一个type前不需要逗号
-
{
-
printf(",");
-
}
-
flag++;
-
if(i < 5) //是pwans则不需要输出"p"或"P"
-
{
-
printf("%c", search[0][i]);
-
}
-
col = (p - chess[n] - 2) / 4 + 'a'; //根据在字符串中的位置 和字符串首地址的差值算出所在column
-
printf("%c%d", col, n + 1);
-
}
-
-
while(p) //可能一个row还没找完剩下一样的type
-
{
-
chess[n][p - chess[n]] = ' '; //如果一行中还有相同的type时,先将找到的那个置为空,避免重复查找
-
-
p = (char*)memchr(chess[n], search[j][i], strlen(chess[n]));
-
if(!p)
-
{
-
break;
-
}
-
-
printf(",");
-
if(i < 5)
-
{
-
printf("%c", search[0][i]);
-
}
-
col = (p - chess[n] - 2) / 4 + 'a';
-
printf("%c%d", col, n + 1);
-
}
-
count++; //按照01234567, 76543210的顺序分别找white和black
-
}
-
i++;
-
}
-
-
if(j == 1)
-
{
-
break;
-
}
-
-
printf("nBlack: ");
-
flag = i = 0;
-
ans = -1;
-
z = 7;
-
j++;
-
}
-
printf("n");
-
-
return 0;
-
}
Problem:User:Memory: 144KTime: 0MSLanguage: CResult:Accepted
2011-04-09 00:20 发表于百度空间,今搬至CU。
阅读(1971) | 评论(0) | 转发(0) |