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 |
这样竟然都能过,难道C和C++的数组是不一样的??//ch[]的大小开为1都能过,以前还从来不知道这么回事。sizeof(ch) == sizeof(ch[0]) = 1 #include <stdio.h> int x, y; char ch[1], map[33][33]; inline void work() { int i, j, k; for(i=0;i<32;i++){ for(j=0;j<32;j++){ map[i][j] = '.'; } } if(ch[0]=='E'||ch[0]=='S'){ y--; } if(ch[0]=='W'||ch[0]=='S'){ x--; } map[y][x] = 'X'; for(k=1; ch[k]!='.'; k++){ if(ch[k]=='E'){ x++; if(ch[k-1]=='N'){ x--; }else if(ch[k-1]=='S'){ y--; } }else if(ch[k]=='N'){ y++; if(ch[k-1]=='W'){ y--; }else if(ch[k-1]=='E'){ x++; } }else if(ch[k]=='W'){ x--; if(ch[k-1]=='N'){ y++; }else if(ch[k-1]=='S'){ x++; } }else if(ch[k]=='S'){ y--; if(ch[k-1]=='E'){ y++; }else if(ch[k-1]=='W'){ x--; } } map[y][x] = 'X'; } } inline void outres() { int i; for(i=31;i>=0;i--){ printf("%s\n",map[i]); } printf("\n"); } int main() { int testcase,i; scanf("%d", &testcase); for(i=1;i<=testcase;i++){ scanf("%d%d%s", &x, &y, ch); work(); printf("Bitmap #%d\n",i); outres(); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator