uva1605 - Building for UN 入门经典II 第八章例题8-2
来源:互联网 发布:苹果5是否支持4g网络 编辑:程序博客网 时间:2024/06/07 04:58
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=825&page=show_problem&problem=4480
分析:按照刘汝佳的思路写的,一共有俩层,每层n行n列,第一层每行相同,第二层每列相同。
举例说明:下面是4个国家 、5个国家的情况。
自己敲的:
#include<cstdio>#include<iostream>using namespace std;int main(){ int n; while(cin >> n){ printf("2 %d %d\n",n,n); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i<26) printf("%c",'a'+i); else printf("%c",'A'+i-26); } printf("\n"); } cout << endl; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(j<26) printf("%c",'a'+j); else printf("%c",'A'+j-26); } printf("\n"); } }}
汝佳提供的代码:
// UVa1605 Building for UN// Rujia Liu#include<cstdio>using namespace std;char country(int i) { if(i < 26) return 'A' + i; return 'a' + i - 26;}int main() { int n; while(scanf("%d", &n) == 1) { printf("2 %d %d\n", n, n); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) printf("%c", country(i)); printf("\n"); } printf("\n"); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) printf("%c", country(j)); printf("\n"); } } return 0;}
0 0
- uva1605 - Building for UN 入门经典II 第八章例题8-2
- Uva1605 Building for UN 【构造法】【例题8-2】
- UVa1605 例题8-2 联合国大楼(Building for UN,ACM/ICPC NEERC 2007)
- 例题8-2 联合国大楼(Building for UN, ACM/ICPC NEERC 2007, UVa1605)
- UVA1605-Building for UN
- UVa1605 Building for UN
- UVa1605 - Building for UN(构造)
- UVA1605 Building for UN (构造)
- UVa1605 Building for UN 构造
- 解题报告 之 UVA1605 Building for UN
- 联合国大楼UVA1605(Building for UN)
- Uva1605——Building for UN
- uva120 Stacks of Flapjacks 入门经典II 第八章例题8-1
- uva1152 - 4 Values whose Sum is 0 入门经典II 第八章 例题8-3
- uva714 - Copying Books 入门经典II 第八章 例题8-10
- uva12627 - Erratic Expansion 入门经典II 第八章 例题8-12
- B - Building for UN
- 1605 - Building for UN
- UVa 11986 - Save from Radiation (推理)
- aabb问题
- 安卓开发之完美解决ADT和SDK不一致问题
- ZOJ 3211 Dream City(DP)
- C# Log4net的使用
- uva1605 - Building for UN 入门经典II 第八章例题8-2
- java.util.concurrent.locks writeread lock 读写锁【3】
- 关于Class.forName(“com.mysql.jdbc.Driver”)
- 免费开源的diff软件“meld”-替代beyond compare的神器
- 查看SDK版本、JDK版本、多个JDK相互切换
- node.js 环境源码安装测试
- ramcloud 5us低时延是如何做到的?
- 如何提高意志力&如何坚持每天学习。
- K-means clustering is not a free lunch