标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 17006 Accepted Submission(s): 4421
#include <iostream> using namespace std; int main() { int n; const int N = 81; char graph[3]; char G[N][N]; int Q=0; while(scanf("%d %c %c", &n, &graph[0], &graph[1]) != EOF) { if(Q !=0) printf("\n"); if(n==1) { Q++; printf("%c\n", graph[0]); continue; } int cnt= 0; int x=0, y=0; int id=n/2%2; char ch=graph[id] ; //printf("%d\n", id); for(int i=0; i< n/2+1; i++) { int start= 0+cnt, end =n-cnt; for(int i=start; i< end; i++) { G[cnt][i]= ch; G[i][cnt]= ch; G[n-cnt-1][i]= ch; G[i][n-cnt-1]= ch; } id= (id==1? 0:1); ch= graph[id]; cnt++; } G[0][0]=‘ ‘; G[0][n-1]=‘ ‘; G[n-1][0]=‘ ‘; G[n-1][n-1]=‘ ‘; for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { //if((i==0 && j==n-1 )|| (i==n-1 && j==n-1)) // continue; printf("%c", G[i][j]); } printf("\n"); } Q++; } return 0; }
标签:
原文地址:http://www.cnblogs.com/fengshun/p/5399222.html