zoukankan      html  css  js  c++  java
  • UVa 1605 联合国大楼

    https://vjudge.net/problem/UVA-1605

    题意:有n个国家,要求设计一栋楼并为这n个国家划分房间,要求国家的房间必须连通,且每两个国家之间必须有一间房间是相邻的。

    思路:乍一看很难的样子,但真的是很简单。一共只要两层,每层都是n*n的,第一层第i行全是国家i,第二层第j列全是国家j。

             但是如果不是这样做的话好像还是挺难的。

             

     1 #include<iostream>  
     2 #include<algorithm>
     3 #include<string>
     4 #include<cstring>
     5 #include<sstream>
     6 using namespace std;
     7 
     8 char ans[60] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
     9 
    10 int n;
    11 
    12 int main()
    13 {
    14     //freopen("D:\txt.txt", "r", stdin);
    15     while (cin>>n && n)
    16     {
    17         cout << "2 " << n << " " << n << endl;
    18         for (int i = 0; i < n; i++)
    19         {
    20             for (int j = 0; j < n; j++)
    21                 cout << ans[i];
    22             cout << endl;
    23         }
    24         cout << endl;
    25         for (int i = 0; i < n; i++)
    26         {
    27             for (int j = 0; j < n; j++)
    28                 cout << ans[j];
    29             cout << endl;
    30         }
    31     }
    32     return 0;
    33 }
  • 相关阅读:
    Linux常用命令大全
    CentOS安装Apche+Mysql+PHP
    ThinkPHP5.1设置404页面
    ThinkPHP5 循环标签
    deepin下安装apache+php+mysql
    deepin安装
    PHP中的http协议
    JSP四个作用域
    application跟session的区别
    jsp内置对象--session
  • 原文地址:https://www.cnblogs.com/zyb993963526/p/6352135.html
Copyright © 2011-2022 走看看