解题思路:
注意事项:
参考代码:
#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语言程序设计教程(第三版)课后习题9.1 (C++代码)浏览:562 |
简单编码 (C++代码)浏览:675 |
C语言考试练习题_一元二次方程 (C语言代码)浏览:735 |
弟弟的作业 (C++代码)浏览:1299 |
C二级辅导-进制转换 (C语言代码)浏览:615 |
A+B for Input-Output Practice (III) (C语言代码)浏览:570 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:574 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:599 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:506 |
简单的a+b (C语言代码)浏览:626 |