解题思路:
注意事项:
参考代码:
#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语言训练-求素数问题 (C语言代码)浏览:722 |
数组输出 (C语言代码)--此题的题目描述有问题浏览:1816 |
数组输出 (C语言代码)错误???浏览:563 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:879 |
C二级辅导-阶乘数列 (C语言代码)浏览:690 |
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C语言代码)浏览:691 |
WU-输出九九乘法表 (C++代码)浏览:1668 |
【绝对值排序】 (C语言代码)浏览:820 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:578 |
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:665 |