码迷,mamicode.com
首页 > 编程语言 > 详细

循环赛算法

时间:2018-02-14 00:41:49      阅读:283      评论:0      收藏:0      [点我收藏+]

标签:names   cst   pre   ios   ret   stream   算法   ==   namespace   

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstdlib>
 4 #include<iomanip>
 5 using namespace std;
 6 int i, j, h, person, n;
 7 int a[32 + 1][32 + 1];
 8 
 9 int main()
10 {
11     cin >> n;
12     person = 1;
13     a[1][1] = 1;
14     h = 1;
15     for(i = 1; i <= n; i++)
16     {
17         person = person * 2;
18     }
19     do
20     {
21         for(i = 1; i <= h; i++)
22         {
23             for(j = 1; j <= h; j++)
24             {
25                 a[i][j + h] = a[i][j] + h;
26                 a[i + h][j] = a[i][j + h];
27                 a[i + h][j + h] = a[i][j];
28             }
29         }
30         h *= 2;
31     }while(!(h == person));
32 
33     for(i = 1; i <= h; i++)
34     {
35         for(j = 1; j <= h; j++)
36         {
37             cout << setw(4) << a[i][j];
38         }
39         cout << endl;
40     }
41     return 0;
42 }

 

循环赛算法

标签:names   cst   pre   ios   ret   stream   算法   ==   namespace   

原文地址:https://www.cnblogs.com/CZT-TS/p/8447762.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!