-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.cpp
More file actions
54 lines (54 loc) · 1.03 KB
/
Copy pathtable.cpp
File metadata and controls
54 lines (54 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<iostream>
using namespace std;
#define N 100
int table[N][N] = {0};
void Print(int n)
{
int i,j;
for(i = 0;i<n;i++)
{
for(j = 0;j<n;j++)
{
cout<<table[i][j]<<' ';
}
cout<<endl;
}
}
void Copy(int nn,int s_xx,int s_yy,int d_xx,int d_yy)
{
int i,j;
for(i = 0;i<nn;i++)
{
for(j = 0;j<nn;j++)
{
table[i+d_xx][j+d_yy] = table[i+s_xx][j+s_yy];
}
}
}
void Table(int nn, int s_xx,int s_yy)
{
if(nn ==1)
return;
else
{
Table(nn/2,s_xx,s_yy);//排好左上角
Table(nn/2,s_xx,s_yy+nn/2);//排好右上角
Copy(nn/2,s_xx,s_yy,s_xx+nn/2,s_yy+nn/2);//将左上角复制到右下角
Copy(nn/2,s_xx,s_yy+nn/2,s_xx+nn/2,s_yy);//将右上角复制到左下角
}
}
int main()
{
int n,i;
int s_x = 0;
int s_y =0;
cout<<"输入想要多少个运动员参加比赛!"<<endl;
cin>>n;
for(i = 0;i<n;i++)
{
table[0][i] = i+1;
}
Table(n,s_x,s_y);
Print(n);
return 0;
}