标签:des style blog http color io os ar strong
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 1318 | Accepted: 703 |
Description
Input
Output
Sample Input
2 0 2
Sample Output
Scenario #1: slice #1: 0
Scenario #2:
slice #1:
.....
.....
..2..
.....
.....
slice #2:
.....
..2..
.212.
..2..
.....
slice #3:
..2..
.212.
21012
.212.
..2..
slice #4:
.....
..2..
.212...2.. ..... slice #5: ..... ..... ..2.. ..... .....
Source
#include <stdio.h> #include <string.h> #include <stdlib.h> int Scenario,Oil,Slice,M[30][30]; void Display() { int i,j; for (i=0;i<Slice;i++) { for (j=0;j<Slice;j++) { if (M[i][j]<=Oil) printf("%d",M[i][j]); else printf("."); } printf("\n"); } } void left_up(int x,int y,int m,int t) { if (m==Oil+1) return; M[x][y]=m; left_up(x-1,y,m+t,t); left_up(x,y-1,m+t,t); } void up_right(int x,int y,int m,int t) { if (m==Oil+1) return; M[x][y]=m; up_right(x+1,y,m+t,t); up_right(x,y-1,m+t,t); } void right_down(int x,int y,int m,int t) { if (m==Oil+1) return; M[x][y]=m; right_down(x+1,y,m+t,t); right_down(x,y+1,m+t,t); } void down_left(int x,int y,int m,int t) { if (m==Oil+1) return; M[x][y]=m; down_left(x,y+1,m+t,t); down_left(x-1,y,m+t,t); } void func(int x,int y,int m,int t) { left_up(x,y,m,t); up_right(x,y,m,t); right_down(x,y,m,t); down_left(x,y,m,t); } int main() { int i,j,x,y; scanf("%d",&Scenario); for(i=1;i<=Scenario;i++) { scanf("%d",&Oil); printf("Scenario #%d:\n",i); if (Oil==0) { printf("slice #1:\n0\n"); } else { Slice=2*Oil+1; for (j=0;j<Slice;j++) { memset(M,10,sizeof(M)); x=Oil; y=Oil; printf("slice #%d:\n",j+1); if (j<=Oil) func(x,y,Oil-j,1); else func(x,y,j-Oil,1); Display(); } } printf("\n"); } return 0; }
注意方位的把握~~~
标签:des style blog http color io os ar strong
原文地址:http://www.cnblogs.com/zhangying/p/4000851.html