拉丁方阵

Posted wsy107316

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了拉丁方阵相关的知识,希望对你有一定的参考价值。

技术图片

 

 技术图片

 

 http://codeup.cn/problem.php?id=22110

 

AC_Code

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int maxn=105;
 5 int n,a[maxn],b[maxn][maxn];
 6 
 7 int main()
 8 {
 9     cin>>n;
10     for(int i=0;i<n;i++) cin>>a[i];
11     for(int i=0;i<n;i++){
12         int pos;
13         for(int j=0;j<n;j++){
14             if( a[j]==i+1 ){
15                 pos=j;
16                 break;
17             }
18         }
19         for(int j=0;j<n;j++){
20             b[j][a[(pos+j)%n]-1]=a[i];
21         }
22     }
23 
24     for(int i=0;i<n;i++){
25         for(int j=0;j<n-1;j++){
26             cout<<b[i][j]<<" ";
27         }
28         cout<<b[i][n-1]<<endl;
29     }
30     return 0;
31 }

 

以上是关于拉丁方阵的主要内容,如果未能解决你的问题,请参考以下文章