题意:给出环的层数和两种图案,按样例要求输出
链接: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;
int l, r, u, d;
string str_1, str_2;
char str[100][1001];
char a, b;
void init()
{
l = 0;
r = n - 1;
u = 0;
d = n - 1;
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, u, d ){
REP ( k, l, r ){
str[j][k] = tmp;
}
}
u ++;
d --;
l ++;
r --;
}
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()
{
ios::sync_with_stdio( false );
bool flag = 0;
while ( cin >> n >> str_1 >> str_2 ){
init();
if ( flag )puts("");
solve();
flag = 1;
}
return 0;
}