1120:同行列对角线的格

#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int main()
{
int n,i,j,x,y;
scanf("%d%d%d",&n,&i,&j);
for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
if(x==i)
cout<<"("<<x<<","<<y<<")"<<" ";
        
}cout<<endl;
    for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
            if(y==j)
                cout<<"("<<x<<","<<y<<")"<<" ";
        
}cout<<endl;
    for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
   if(x-y==i-j)
cout<<"("<<x<<","<<y<<")"<<" ";       

}cout<<endl;
    for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
if(x+y==i+j)
cout<<"("<<y<<","<<x<<")"<<" ";
        
}cout<<endl;
return 0;
}100'

猜你喜欢

转载自blog.csdn.net/qq_42552468/article/details/80994753