HDOJ 2074 叠筐
来源:互联网 发布:无线通信与网络 编辑:程序博客网 时间:2024/05/22 03:14
题意:实现如样例的图形,输入三个数据,分别为层数,中心图案,外框图案
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2074
思路:模拟水题,直接看代码吧。
注意点:注意两个图案的顺序。
以下为AC代码:
Run IDSubmit TimeJudge StatusPro.IDExe.TimeExe.MemoryCode Len.LanguageAuthor129761332015-02-22 15:53:15Accepted20740MS1304K2421 BG++luminous11#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <vector>#include <deque>#include <list>#include <cctype>#include <algorithm>#include <climits>#include <queue>#include <stack>#include <cmath>#include <map>#include <set>#include <iomanip>#include <cstdlib>#include <ctime>#define ll long long#define ull unsigned long long#define all(x) (x).begin(), (x).end()#define clr(a, v) memset( a , v , sizeof(a) )#define pb push_back#define RDI(a) scanf ( "%d", &a )#define RDII(a, b) scanf ( "%d%d", &a, &b )#define RDIII(a, b, c) scanf ( "%d%d%d", &a, &b, &c );#define RDS(s) scanf ( "%s", s );#define PIL(a) printf ( "%d\n", a );#define PIIL(a,b) printf ( "%d %d\n", a, b );#define PIIL(a,b,c) printf ( "%d %d %d\n", a, b, c );#define PSL(s) printf ( "%s\n", s );#define REP(i,m,n) for ( int i = m; i <= n; i ++ )#define DEP(i,m,n) for ( int i = m; i >= n; i -- )#define REPI(i,m,n,k) for ( int i = m; i <= n; i += k )#define DEPI(i,m,n,k) for ( int i = m; i >= n; i -= k )#define read(f) freopen(f, "r", stdin)#define write(f) freopen(f, "w", stdout)using namespace std;const double pi = acos(-1);const double eps = 1e-10;const int dir[4][2] = { 1,0, -1,0, 0,1, 0,-1 };struct node{ int x, y, cnt; node(){} node( int _x, int _y ) : x(_x), y(_y) {} node( int _x, int _y, int _cnt ) : x(_x), y(_y), cnt(_cnt) {}};int n;string str_1, str_2;char str[100][1001];char a, b;void init(){ clr ( str, 0 ); a = str_1[0]; b = str_2[0]; if ( ( n - 1 ) % 4 == 0 ) swap ( a, b );}void solve(){ char tmp; REP ( i, 0, ( n - 1 ) / 2 ){ if ( i & 1 ) tmp = a; else tmp = b; REP ( j, i, n - 1 - i ) REP ( k, i, n - 1 - i ) str[j][k] = tmp; } if ( n != 1 ) str[0][0] = str[0][n-1] = str[n-1][0] = str[n-1][n-1] = ' '; REP ( i, 0, n - 1 ) PSL ( str[i] );}int main(){ bool flag = 0; while ( cin >> n >> str_1 >> str_2 ){ init(); if ( flag )puts(""); solve(); flag = 1; } return 0;}
0 0
- hdoj.2074 叠筐 20140804
- hdoj 2074 叠筐
- HDOJ 2074 叠筐
- HDOJ 2074 叠筐
- HDOJ 2074 叠筐
- HDOJ
- hdoj
- hdoj
- HDOJ
- hdoj 1568 && hdoj 5344 && hdoj 5444
- HDOJ 2176
- Hdoj--1272
- hdoj 1003
- hdoj 1005
- hdoj 1030
- hdoj 2154
- hdoj 2100
- HDOJ 1106
- Cocos Studio编辑器使用教程 -- 常见问题汇总
- OLEDB和ODBC的区别
- poj 3107 Godfather(树形dp,树的重心)
- Cocos Studio2.0发布的资源在Cocos2d-x中的使用简介
- spring学习之常用的注解
- HDOJ 2074 叠筐
- 基于Cocos Studio 2.0获取某个节点的方法
- d叉堆 d-ary
- NOJ1042 区间最值 裸RMQ
- 【线性回归笔记】局部加权回归
- 优先队列的使用
- [LeetCode OJ][004]Median of Two Sorted Arrays
- 新手学C++ 运行代码时候闪退怎么办啊?
- LeetCode Divide Two Integers