11 B A 5 @ W
AAAAAAAAA ABBBBBBBBBA ABAAAAAAABA ABABBBBBABA ABABAAABABA ABABABABABA ABABAAABABA ABABBBBBABA ABAAAAAAABA ABBBBBBBBBA AAAAAAAAA @@@ @WWW@ @W@W@ @WWW@ @@@
#include<iostream> #include<cstring> using namespace std; int main() { int n; char c1,c2,k=0; while(cin>>n) { cin>>c1>>c2; int i,j,m,p,q; char str[81][81]; memset(str,0,sizeof(str)); p=0;q=n-1;m=(n-1)/2; if(k++) cout<<endl; if(n==1) cout<<c1<<endl; else { while(m<=q) { if((q-p+1)%4==3) { for(i=p;i<=q;i++) for(j=p;j<=q;j++) str[i][j]=c2; p++;q--; } else { for(i=p;i<=q;i++) for(j=p;j<=q;j++) str[i][j]=c1; p++;q--; } } str[0][0]=str[n-1][0]=str[0][n-1]=str[n-1][n-1]=' '; for(i=0;i<n;i++) cout<<str[i]<<endl; } } return 0; }
原文地址:http://blog.csdn.net/hyccfy/article/details/38042355