Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
G++ TLE,C AC....#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define MAX 729 int n; char s[MAX][MAX]; int main() { int i,j,k,p,q; memset(s,' ',sizeof(s)); s[0][0]='X'; for(i=0;i<6;i++) { k=(int)pow(3,i); for(p=0;p<k;p++) { for(q=0;q<k;q++) { if(s[p][q]=='X'); { s[p][q+2*k]=s[p][q]; s[p+k][q+k]=s[p][q]; s[p+2*k][q]=s[p][q]; s[p+2*k][q+2*k]=s[p][q]; } } } } while((scanf("%d",&n))&&(n!=-1)) { k=(int)pow(3,n-1); for(i=0;i<k;i++) { for(j=0;j<k;j++) printf("%c",s[i][j]); printf("\n"); } printf("-\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator