Codeforces Round #259 (Div. 2), problem: (A) Little Pony and Crystal Mine editorial: http://codeforces.com/blog/entry/13190
Codeforces Round #259 (Div. 2), problem: (A) Little Pony and Crystal Mine solution:
#include <iostream> #include <cstdio> using namespace std; int main() { int n; char s[105][105]; scanf("%d", &n); for(int i=0; i<n; i++) s[n/2][i]='D'; for(int i=n/2-1, k=0; i>=0; i--, k++) for(int j=0; j<=k; j++) s[i][j]=s[i][n-1-j]=s[n-1-i][j]=s[n-1-i][n-1-j]='*'; for(int i=0; i<n; i++) for(int j=0; j<n; j++) if(s[i][j]!='*' && s[i][j]!='D') s[i][j]='D'; for(int i=0; i<n; i++) { for(int j=0; j<n; j++) printf("%c", s[i][j]); printf("\n"); } return 0; }
No comments:
Post a Comment