HDU 2074 叠筐(基础字符串处理)
来源:互联网 发布:ace.min.js是什么 编辑:程序博客网 时间:2024/05/21 19:40
本题是一个字符串处理画图题,很多人都把它归为水题,的确思路不难,但是这题需要考虑的东西很多,例如:
1、N=1的情况
2、四个角的处理
3、输出与输出之间的空行
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<iostream>#include <set> #include <string> #include <sstream>#define clear(n,m) memset(n,m,sizeof(n))#define ll long longusing namespace std;char s[85][85];int main(){ int n; bool flag = false; while (cin >> n) { char a, b; cin >> a >> b; if (flag) cout << endl; if (n == 1) { cout << a << endl; continue; } int x = n / 2 + 1; s[x][x] = a; for (int i = 1;i <= n/2;i++) { for (int j = x-i;j <= x+i;j++) { if (i % 2) { s[x - i][j] = s[x + i][j] = s[j][x - i] = s[j][x + i] = b; } else { s[x - i][j] = s[x + i][j] = s[j][x - i] = s[j][x + i] = a; } } } s[1][n] = s[1][1] = s[n][1] = s[n][n] = ' '; for (int i = 1;i <= n;i++) { for (int j = 1;j <= n;j++) cout << s[i][j]; cout << endl; } flag = true; } return 0;}
0 0
- HDU 2074 叠筐(基础字符串处理)
- HDU 1013 Digital Roots 数字根 字符串处理基础题
- HDU——2970(字符串处理)
- HDU 1062 Text Reverse(字符串处理)
- HDU 5083 Instruction(字符串处理)
- hdu 1236 排名 (字符串处理)水题
- HDU-1228-A+B(字符串处理)
- HDU 2072 单词数(字符串处理)
- hdu 5455 Fang Fang(字符串处理)
- HDU-5938 Four Operations(字符串处理)
- HDU 2072 字符串处理(判重)
- HDU-1039 字符串处理
- hdu 1062 字符串处理
- hdu 1048 字符串处理
- hdu 1062 字符串处理
- hdu 1106 字符串处理
- HDU 5056 字符串处理
- 字符串处理 hdu 1048
- Webpack学习心得
- bash之字符串处理
- C++编码规则----布局
- cc1plus: all warnings being treated as errors
- Effective java笔记-第九章-异常
- HDU 2074 叠筐(基础字符串处理)
- 欢迎使用CSDN-markdown编辑器
- 页表 段表
- JAVA-练习:购物金额结算
- 文件上传之进度条与图片类型检测
- 1029: 求矩阵的两对角线上的元素之和
- Write a Servlet Application that uses a cookie to track the number of times a user visits a web site
- TRIP数据库简介
- java编译时异常和运行时异常