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