Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
William Sha
ai01_tp1
Commits
f306103d
Commit
f306103d
authored
Nov 22, 2017
by
William Sha
Browse files
Merge remote-tracking branch 'origin/master'
parents
b18d4aa1
83d20940
Changes
1
Hide whitespace changes
Inline
Side-by-side
tp3.c
View file @
f306103d
...
...
@@ -108,16 +108,15 @@ int insert_after_position(List** list, char* str, int p){
if
(
p
==
1
||
length
==
0
){
insert_beginning_list
(
list
,
str
);
return
1
;
return
0
;
}
if
(
p
==
length
||
((((
*
list
)
->
head
!=
NULL
)
&
((
*
list
)
->
head
==
(
*
list
)
->
tail
)))){
insert_end_list
(
list
,
str
);
return
1
;
return
0
;
}
Element
*
parcour
=
(
*
list
)
->
head
;
printf
(
"1
\n
"
);
int
compteur
=
0
;
while
(
p
!=
compteur
){
...
...
@@ -126,16 +125,13 @@ int insert_after_position(List** list, char* str, int p){
compteur
++
;
}
//a la sortie parcour est à l'element de delimitation de l'element p
printf
(
"2
\n
"
);
List
*
tempList
;
initialize
(
&
tempList
);
insert_empty_list
(
&
tempList
,
str
);
printf
(
"3
\n
"
);
tempList
->
tail
->
next
=
parcour
->
next
;
parcour
->
next
=
tempList
->
head
;
free
(
tempList
);
//display(*list);
return
1
;
return
0
;
}
int
remove_element
(
List
*
list
,
int
p
){
...
...
@@ -143,8 +139,10 @@ int remove_element(List* list, int p){
printf
(
"List pointer is null.
\n
"
);
return
-
1
;
}
int
length
;
length
=
lengthList
(
list
);
if
(
p
<=
0
){
if
(
p
<=
0
||
p
>
length
){
printf
(
"The provided value for the position is incorrect.
\n
"
);
return
-
1
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment