5 solutions
-
5
有注释😄不怕康不懂
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv){ int n,i,j; cin >> n >> i >> j; // 同一行上格子的位置 for (int y = 1;y <= n;y++){ printf("(%d,%d) ",i,y); } cout << "\n"; // 同一列上格子的位置 for (int x = 1;x <= n;x++){ printf("(%d,%d) ",x,j); } cout << "\n"; // 左上到右下对角线上的格子的位置 for (int x = 1;x <= n;x++){ // 左到右 for (int y = 1;y <= n;y++){ // 上到下 if (i - x == j - y){ // 判断是否为对角线 printf("(%d,%d) ",x,y); } } } cout << "\n"; // 左下到右上对角线上的格子的位置 for (int x = n;x > 0;x--){ // 右到左 for (int y = n;y > 0;y--){ // 下到上 if (x - i == j - y){ // 判断是否为对角线 printf("(%d,%d) ",x,y); } } } return 0; }
-
2
#include<bits/stdc++.h> using namespace std; int n,x,y; int main(){ cin>>n>>x>>y; for(int i=1;i<=n;i++) cout<<"("<<x<<","<<i<<")"<<" "; cout<<endl; for(int i=1;i<=n;i++) cout<<"("<<i<<","<<y<<")"<<" "; cout<<endl; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(i-j==x-y) cout<<"("<<i<<","<<j<<")"<<" "; cout<<endl; for(int i=n;i>=1;i--) for(int j=1;j<=n;j++) if(i+j==x+y) cout<<"("<<i<<","<<j<<")"<<" "; cout<<endl; return 0; }
-
0
#include<bits/stdc++.h> using namespace std; short N,i,j; int main(){ cin>>N>>i>>j; for(int z=1;z<=N;z++){ cout<<'('<<i<<','<<z<<')'<<' '; }cout<<endl;//遍历竖行 for(int k=1;k<=N;k++){ cout<<'('<<k<<','<<j<<')'<<' '; }cout<<endl;//遍历横行 for(int k=1;k<=N;k++){ for(int z=1;z<=N;z++){ if(k-z==i-j) cout<<'('<<k<<','<<z<<')'<<' ';} }cout<<endl; //规律=横竖之差相等 //例(1,2) (2,3) (3,4) 1-2=2-3=3-4 //1 2 3 4 //* x * * 1 //* * x * 2 //* * * x 3 //* * * * 4 for(int k=1;k<=N;k++){ for(int z=1;z<=N;z++){ if(k+z==i+j) cout<<'('<<z<<','<<k<<')'<<' ';} }cout<<endl; //规律=横竖之和相等 //例(4,1) (3,2) (2,3) (1,4) 4+1=3+2=2+3=1+4 //1 2 3 4 //* * * x 1 //* * x * 2 //* x * * 3 //x * * * 4 return 0;}
-
0
#include<bits/stdc++.h> using namespace std; int main() { int n,x,y; cin>>n>>x>>y; for(int i=1;i<=n;i++){ cout<<"("<<x<<","<<i<<")"<<" "; } cout<<endl; for(int i=1;i<=n;i++){ cout<<"("<<i<<","<<y<<")"<<" "; } cout<<endl; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i-j==x-y){ cout<<"("<<i<<","<<j<<")"<<" "; } } } cout<<endl; for(int i=n;i>=1;i--){ for(int j=1;j<=n;j++){ if(i+j==x+y){ cout<<"("<<i<<","<<j<<")"<<" "; } } } cout<<endl; return 0; }
-
0
`
#include<bits/stdc++.h> using namespace std; int main() { int n,x,y; cin>>n>>x>>y; for(int i=1;i<=n;i++){ cout<<"("<<x<<","<<i<<")"<<" "; } cout<<endl; for(int i=1;i<=n;i++){ cout<<"("<<i<<","<<y<<")"<<" "; } cout<<endl; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i-j==x-y){ cout<<"("<<i<<","<<j<<")"<<" "; } } } cout<<endl; for(int i=n;i>=1;i--){ for(int j=1;j<=n;j++){ if(i+j==x+y){ cout<<"("<<i<<","<<j<<")"<<" "; } } } cout<<endl; return 0; }
- 1
Information
- ID
- 606
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- # Submissions
- 236
- Accepted
- 53
- Uploaded By