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
57736f6f
Commit
57736f6f
authored
Nov 22, 2017
by
William Sha
Browse files
Minor
docx, main and tp3
parent
1d753eef
Changes
3
Hide whitespace changes
Inline
Side-by-side
ai01_tp1.docx
View file @
57736f6f
No preview for this file type
main.c
View file @
57736f6f
...
...
@@ -20,7 +20,6 @@ int main()
initialize
(
&
default_list
);
while
(
action
!=
8
){
if
(
DEBUG
)
printf
(
"Entering in a new menu prompt...
\n\n
"
);
action
=
0
;
// action prompt
...
...
tp3.c
View file @
57736f6f
...
...
@@ -230,6 +230,7 @@ int compare(char* str1, char* str2){
}
int
sort
(
List
*
list
){
// tri à bulles
if
(
DEBUG
)
printf
(
"Sorting in progress...
\n
"
);
int
l
=
lengthList
(
list
);
if
(
!
list
){
...
...
@@ -241,8 +242,8 @@ int sort(List* list){ // tri à bulles
return
0
;
// rien à trier
}
char
*
n1
=
malloc
(
sizeof
(
char
)
*
256
);
n1
[
0
]
=
'\0'
;
char
*
n2
=
malloc
(
sizeof
(
char
)
*
256
);
n2
[
0
]
=
'\0'
;
char
*
n1
=
malloc
(
sizeof
(
char
)
*
128
);
n1
[
0
]
=
'\0'
;
char
*
n2
=
malloc
(
sizeof
(
char
)
*
128
);
n2
[
0
]
=
'\0'
;
Element
*
start
,
*
interval
,
*
fh
,
*
ft
,
*
sh
,
*
st
,
*
read
,
*
ox
;
// start, firsthead, firsttail, secondhead, secondtail
// pour faire le tri à bulles, il faut repérer les deux nombres par leurs débuts et leurs fins, d'oû 4 pointeurs d'élement fh ft sh st
// cela nous servira pour les facilement switcher les nombres
...
...
@@ -255,6 +256,7 @@ int sort(List* list){ // tri à bulles
ft
=
fh
->
next
;
}
while
(
interval
!=
list
->
head
){
do
// un passage de bulle
{
...
...
@@ -269,6 +271,7 @@ int sort(List* list){ // tri à bulles
for
(
read
=
sh
;
read
!=
st
->
next
;
read
=
read
->
next
){
// on lit la première valeur
n2
=
strcat
(
n2
,
read
->
data
);
// concatenation
}
if
(
DEBUG
)
printf
(
"Comparing...
\n
"
);
if
(
compare
(
n1
,
n2
)
==
1
){
ox
=
st
->
next
;
st
->
next
=
ft
->
next
;
...
...
@@ -328,10 +331,11 @@ void display(List* list){
c
=
lengthList
(
list
);
Element
*
p
=
list
->
head
;
printf
(
"| "
);
for
(
p
=
list
->
head
;
p
!=
NULL
;
p
=
p
->
next
){
printf
(
"
element:
%s
\n
"
,
p
->
data
);
printf
(
" %s
|
"
,
p
->
data
);
}
//
printf("
DATA : %c", list->head->data[0]
);
printf
(
"
\n\n
"
);
}
...
...
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