解题思路:
注意事项:
参考代码:
#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语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:740 |
C语言训练-数字母 (C语言代码)浏览:585 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:524 |
回文串 (C语言代码)浏览:2862 |
WU-小九九 (C++代码)浏览:1684 |
C语言程序设计教程(第三版)课后习题9.3 (C语言代码)浏览:2092 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:567 |
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:647 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:577 |
C二级辅导-计负均正 (C语言代码)浏览:482 |