天哪,这次考试,第二道题太亏了!!!!
就因为多输出一行空格,0分。。。。。
加油,不抛弃,不放弃,一定会成功的,只要持之以恒就行,共勉!!!
#include<iostream>
using namespace std;
const int N=1000;
struct node{
int x,y;
};
node a[N];
int main(){
int n;
cin >> n;
int b[5];
for(int i = 0; i < 5; i++){
b[i] = 0;
}
for(int i = 0; i < n; i++){
cin >> a[i].x >> a[i].y;
}
for(int i = 0; i < n; i++){
int t = 0;
int sum = 0;
int x=a[i].x;
int y=a[i].y;
for(int j = 0; j < n; j++){
int x1=a[j].x;
int y1=a[j].y;
if(i == j){
continue;
}else{
if(x-1==x1 && y==y1){
t++;
}else if(x+1==x1 && y==y1){
t++;
}else if(x==x1 && y-1==y1){
t++;
}else if(x==x1 && y+1==y1){
t++;
}
}
}
if(t == 4){
for(int j = 0; j < n; j++){
int x1=a[j].x;
int y1=a[j].y;
if(i == j){
continue;
}else{
if((x-1==x1 && y+1==y1)){
sum++;
}else if((x+1==x1 && y+1==y1)){
sum++;
}else if((x-1==x1 && y-1==y1)){
sum++;
}else if((x+1==x1 && y-1==y1)){
sum++;
}
}
}
b[sum] += 1;
sum = 0;
}
t = 0;
}
//cout << endl; 考试多加了一行,0分
for(int i = 0; i < 5; i++){
cout << b[i] << endl;
}
return 0;
}