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 |
大家来救我啊!!! Advanced ASCII Cubes 我和答案输出的样子一样,为什么老是错啊!!! 请指教(内含代码)这是我的代码: #include <stdio.h> #include <memory.h> #define MAXN 1000 char mp[MAXN][MAXN]; int h[55][55]; int mrow,mcol; int row,col; void out(void) { register int i,j; for(i=1;i<=mrow;i++) { for(j=1;j<=mcol;j++) putchar(mp[i][j]); if(i!=mrow) putchar('\n'); } } void print1(int srow,int scol) { register int k; if(mp[srow][scol]=='.') mp[srow][scol]='+'; for(k=scol+1;k<=scol+3;k++) if(mp[srow][k]=='.') mp[srow][k]='-'; if(mp[srow][k]=='.') mp[srow][k]='+'; if(mp[srow-1][k+1]=='.') mp[srow-1][k+1]='/'; if(mp[srow-2][k+2]=='.') mp[srow-2][k+2]='+'; } void print2(int srow,int scol) { register int k; if(mp[srow-1][scol]=='.') mp[srow-1][scol]='|'; if(mp[srow-2][scol]=='.') mp[srow-2][scol]='|'; if(mp[srow-1][scol+4]=='.') mp[srow-1][scol+4]='|'; if(mp[srow-2][scol+4]=='.') mp[srow-2][scol+4]='|'; if(mp[srow-3][scol+6]=='.') mp[srow-3][scol+6]='|'; if(mp[srow-4][scol+6]=='.') mp[srow-4][scol+6]='|'; for(k=scol+1;k<=scol+3;k++) { if(mp[srow-1][k]=='.') mp[srow-1][k]=' '; if(mp[srow-2][k]=='.') mp[srow-2][k]=' '; } if(mp[srow-2][scol+5]=='.') mp[srow-2][scol+5]=' '; if(mp[srow-3][scol+5]=='.') mp[srow-3][scol+5]=' '; } int main() { register int i,j,k; scanf("%d%d",&row,&col); for(i=1;i<=row;i++) for(j=1;j<=col;j++) { scanf("%d",&h[i][j]); if(4*h[i][j]+1+2*(row-i)>mrow) mrow=3*h[i][j]+3+2*(row-i); } mcol=4*col+1+2*row; for(i=1;i<=mrow;i++) for(j=1;j<=mcol;j++) mp[i][j]='.'; for(i=row;i>=1;i--) for(j=col;j>=1;j--) { int srow=mrow-2*(row-i); int scol=2*(row-i)+4*(j-1)+1; for(k=0;k<=h[i][j];k++) { print1(srow-3*k,scol); if(k==h[i][j]) break; print2(srow-3*k,scol); } int ttrow=srow-(3*h[i][j]+3)+1; int ttcol=scol+2; if(mp[ttrow+1][ttcol-1]=='.') mp[ttrow+1][ttcol-1]='/'; if(mp[ttrow+1][ttcol+3]=='.') mp[ttrow+1][ttcol+3]='/'; if(mp[ttrow][ttcol]=='.') mp[ttrow][ttcol]='+'; for(k=ttcol+1;k<=ttcol+3;k++) if(mp[ttrow][k]=='.') mp[ttrow][k]='-'; if(mp[ttrow][k]=='.') mp[ttrow][k]='+'; for(k=ttcol;k<=ttcol+2;k++) if(mp[ttrow+1][k]=='.') mp[ttrow+1][k]=' '; } out(); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator