zoukankan      html  css  js  c++  java
  • 循环赛算法

     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 }
  • 相关阅读:
    2014-04-23 总结
    14-5-13
    PHP
    14-5-8
    ajax
    14-5-6
    14-5-5
    PHP初解
    14-4-30
    14-4-29
  • 原文地址:https://www.cnblogs.com/CZT-TS/p/8447762.html
Copyright © 2011-2022 走看看