3种
2024-11-05 20:34:39
发布于:上海
0阅读
0回复
0点赞
/*#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,x,y;
cin>>a>>b>>x>>y;
if(y+1<=b)
cout<<x<<" "<<y+1;
else
cout<<"NA";
cout<<endl;
if(x+1<=a)
cout<<x+1<<" "<<y;
else
cout<<"NA";
cout<<endl;
if(y-1>=1)
cout<<x<<" "<<y-1;
else
cout<<"NA";
cout<<endl;
if(x-1>=1)
cout<<x-1<<" "<<y;
else
cout<<"NA";
cout<<endl;
}
*/
/*
#include<bits/stdc++.h>
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
int main()
{
int x,y,x1,y1;
cin>>x>>y>>x1>>y1;
for(int i = 0;i<4;i++)
{
if(x1+dx[i]>x||x1+dx[i]<=0||y1+dy[i]>y||y1+dy[i]<=0)
cout<<"NA"<<endl;
else
cout<<x1+dx[i]<<" "<<y1+dy[i]<<endl;
}
}
*/
#include<bits/stdc++.h>
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
bool pd(int x,int y,int x1,int y1,int i)
{
return (x1+dx[i]>x||x1+dx[i]<=0||y1+dy[i]>y||y1+dy[i]<=0);
}
int main()
{
int x,y,x1,y1;
cin>>x>>y>>x1>>y1;
for(int i = 0;i<4;i++)
{
if(pd(x,y,x1,y1,i))
cout<<"NA"<<endl;
else
cout<<x1+dx[i]<<" "<<y1+dy[i]<<endl;
}
}
这里空空如也
有帮助,赞一个