File tree Expand file tree Collapse file tree 5 files changed +52
-1
lines changed Expand file tree Collapse file tree 5 files changed +52
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" standalone =" yes" ?>
2
+ <CodeBlocks_layout_file >
3
+ <ActiveTarget name =" Debug" />
4
+ <File name =" main.c" open =" 1" top =" 1" tabpos =" 1" split =" 0" active =" 1" splitpos =" 0" zoom_1 =" 0" zoom_2 =" 0" >
5
+ <Cursor >
6
+ <Cursor1 position =" 273" topLine =" 78" />
7
+ </Cursor >
8
+ </File >
9
+ </CodeBlocks_layout_file >
Original file line number Diff line number Diff line change @@ -44,14 +44,56 @@ status initList( LinkList *L )
44
44
p = q ;
45
45
}
46
46
47
+ q -> next = (* L )-> next ;
48
+
47
49
return OK ;
48
50
}
49
51
52
+ //依次报数,报3的人自杀。
53
+ status order4Kill ( LinkList * L )
54
+ {
55
+ int i = 0 ;
56
+ int j = 1 ;
57
+
58
+ Node * p , * q ;
59
+
60
+ p = (* L );
61
+
62
+ while ( TRUE )
63
+ {
64
+ i ++ ;
65
+ p = p -> next ;
66
+
67
+ if ( !p )
68
+ return OK ;
69
+
70
+ if ( i == 2 )
71
+ {
72
+ q = p -> next ;
73
+
74
+ p -> next = p -> next -> next ;
75
+ p = p -> next ;
76
+
77
+ printf ("%d," , q -> data );
78
+ q -> next = NULL ;
79
+ free (q );
80
+
81
+ if ( j %13 == 0 )
82
+ printf ("\n" );
83
+
84
+ i = 1 ;
85
+ j ++ ;
86
+ }
87
+ }
88
+ }
89
+
50
90
int main ()
51
91
{
52
92
LinkList list = NULL ;
53
93
54
94
initList (& list );
55
95
96
+ order4Kill (& list );
97
+
56
98
return 0 ;
57
99
}
Original file line number Diff line number Diff line change 3
3
<ActiveTarget name =" Debug" />
4
4
<File name =" main.c" open =" 1" top =" 1" tabpos =" 1" split =" 0" active =" 1" splitpos =" 0" zoom_1 =" 0" zoom_2 =" 0" >
5
5
<Cursor >
6
- <Cursor1 position =" 559 " topLine =" 0 " />
6
+ <Cursor1 position =" 2743 " topLine =" 163 " />
7
7
</Cursor >
8
8
</File >
9
9
</CodeBlocks_layout_file >
You can’t perform that action at this time.
0 commit comments