题意:实现如样例的图形,输入三个数据,分别为层数,中心图案,外框图案
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2074
思路:模拟水题,直接看代码吧。
注意点:注意两个图案的顺序。
以下为AC代码:
Run ID | Submit Time | Judge Status | Pro.ID | Exe.Time | Exe.Memory | Code Len. | Language | Author |
12976133 | 2015-02-22 15:53:15 | Accepted | 2074 | 0MS | 1304K | 2421 B | G++ | 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;
}