解题思路:
注意事项:
参考代码:
#include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<bits/stdc++.h> using namespace std; int x[1001],y[1001],count1[1001],po=1; int n; int tx[21]={0,2,-2,1,-1,2,-2,1,-1}; int ty[21]={0,1,-1,2,-2,-1,1,-2,2}; int main() { cin>>n; for(int i=1;i<=n;i++) { char a[3]; for(int j=1;j<=2;j++) { cin>>a[j]; } x[i]=a[1]-96; y[i]=a[2]-'0'; } int tem=n; while(n>0){ for(int i=1;i<=8;i++) { int fx=tx[i]+x[po]; int fy=ty[i]+y[po]; if(fx>0&&fx<=8&&fy>0&&fy<=8) { count1[po]++; } } n--; po++; } for(int i=1;i<=tem;i++) { cout<<count1[i]<<endl; } return 0; }
0.0分
0 人评分
钟神赛车 (C++代码)浏览:864 |
【计算两点间的距离】 (C语言代码)浏览:879 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:665 |
printf基础练习2 (有点不明白)浏览:836 |
C语言训练-计算t=1+1/2+1/3+...+1/n (C语言代码)浏览:904 |
用筛法求之N内的素数。 (C语言代码)浏览:802 |
三角形 (C语言代码)浏览:903 |
母牛的故事 (C语言代码)浏览:549 |
矩阵加法 (C语言代码)浏览:1719 |
DNA (C语言代码)浏览:745 |