Size: 2406
Comment:
|
Size: 2954
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 6: | Line 6: |
::-- hoxide [[[DateTime(2005-04-02T06:31:12Z)]]] | ---- /!\ '''Edit conflict - other version:''' ---- ::-- hoxide [[[DateTime(2005-04-02T06:32:37Z)]]] ---- /!\ '''Edit conflict - your version:''' ---- ::-- hoxide [[[DateTime(2005-04-02T06:38:10Z)]]] ---- /!\ '''End of edit conflict''' ---- |
Line 12: | Line 19: |
=== 第七题 === | ---- /!\ '''Edit conflict - other version:''' ---- === 小节标题1 === |
Line 15: | Line 24: |
---- /!\ '''Edit conflict - your version:''' ---- === 小节标题1 === {{{ #!cplusplus ---- /!\ '''End of edit conflict''' ---- |
|
Line 125: | Line 143: |
---- /!\ '''Edit conflict - other version:''' ---- ---- /!\ '''Edit conflict - your version:''' ---- ---- /!\ '''End of edit conflict''' ---- |
含有章节索引的中文 文章模板
Edit conflict - other version:
::-- hoxide [DateTime(2005-04-02T06:32:37Z)]
Edit conflict - your version:
::-- hoxide [DateTime(2005-04-02T06:38:10Z)]
End of edit conflict
文章大标
简述
章标题1
Edit conflict - other version:
小节标题1
1 ---- /!\ '''Edit conflict - your version:''' ----
2 === 小节标题1 ===
3 {{{
4 #!cplusplus
5
6
7 ---- /!\ '''End of edit conflict''' ----
8 #include <stdio.h>
9 #include <string.h>
10 #include <stdlib.h>
11
12 #define TPS 4
13
14 #define STEP \
15 do { \
16 tt =1; \
17 for(; d<TPS; d++) \
18 { \
19 tr=r+tp[d][0], tc=c+tp[d][1]; \
20 if (tr>=0 && tr <n && tc>=0 && tc <m && p[tr][tc]=='.') \
21 { r = tr, c = tc; \
22 p[r][c] = '0'+d; \
23 st[t] = d; \
24 t++, s++; \
25 tt = 0; \
26 break; \
27 } \
28 } \
29 } while(0)
30
31
32 #define OMAX 25
33
34 void printp(int n, int m, char **p)
35 {
36 int i, j;
37 fprintf(stdout, "\n");
38 for(i=0; i<n; i++)
39 {
40 for(j=0; j<m; j++)
41 fprintf(stdout, "%c", p[i][j]);
42 fprintf(stdout, "\n");
43 }
44 }
45
46 int count(int n, int m, char **p)
47 {
48 int st[OMAX*OMAX];
49 int s, d;
50 int tt;
51 signed int t;
52 signed int r, c, tr, tc;
53 int tp[TPS][2] = { {+1, 0}, {-1, 0}, {0, +1}, {0, -1} };
54 //printp(n,m,p);
55 for(r=0; r<n; r++)
56 {
57 for(c=0; c<m; c++)
58 if(p[r][c]=='@')
59 break;
60 if(p[r][c]=='@')
61 break;
62 }
63 for(s=1, st[0]=TPS, t=1; t>0;)
64 {
65 d=0;
66 STEP;
67 //fprintf(stderr, "(%d, %d)\t", r, c);
68 //printp(n,m,p);
69
70 while (t>0 && tt == 1)
71 {
72 t--;
73 d = st[t];
74 r -= tp[d][0];
75 c -= tp[d][1];
76 d++;
77 STEP;
78 //fprintf(stderr, "(%d, %d)\t", r, c);
79 }
80 }
81 return s;
82 }
83
84 int pp(char **p)
85 {
86 int n, m;
87 int i;
88 fscanf(stdin, "%d%d", &m, &n);
89 for(i=0; i<n ;i++)
90 fscanf(stdin,"%s", p[i]);
91
92 if(n==0 || m==0)
93 return 0;
94 else
95 return count(n, m, p);
96 }
97
98 int main()
99 {
100 int i;
101 char **p;
102 p = (char **)malloc(sizeof(char*)*OMAX);
103 for(i=0; i< OMAX; i++)
104 p[i]=(char *)malloc(sizeof(char)*OMAX);
105 do
106 {
107 i=pp(p);
108 if(i!=0)
109 fprintf(stdout, "%d\n", i);
110 }
111 while(i!=0);
112
113 return 0;
114 }
115
116
117
118 ---- /!\ '''Edit conflict - other version:''' ----
119
120 ---- /!\ '''Edit conflict - your version:''' ----
121
122 ---- /!\ '''End of edit conflict''' ----
次节标题1
xxx
章标题2
小节标题2
其它 代码引用
次节标题2
yyy