Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Eval_Prog_Sec_2_Bach
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
joachim.bach
Eval_Prog_Sec_2_Bach
Commits
d51823ba
Commit
d51823ba
authored
2 years ago
by
joachim.bach
Browse files
Options
Downloads
Patches
Plain Diff
finished exa
parent
1b0d9c5b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
exo1/exo1.c
+202
-0
202 additions, 0 deletions
exo1/exo1.c
exo3/exo3
+0
-0
0 additions, 0 deletions
exo3/exo3
with
202 additions
and
0 deletions
exo1/exo1.c
+
202
−
0
View file @
d51823ba
...
...
@@ -5,9 +5,211 @@
#include
<stdlib.h>
#include
<stdbool.h>
#include
<time.h>
#include
<malloc.h>
typedef
struct
_element
{
int
data
;
struct
_element
*
next
;
}
element
;
typedef
struct
_list
{
element
*
head
;
element
*
pos
;
}
list
;
void
list_destroy
(
list
*
list
)
{
list
->
pos
=
list
->
head
;
while
(
list
->
pos
->
next
!=
NULL
)
{
element
*
tmp
=
list
->
pos
;
list
->
pos
=
list
->
pos
->
next
;
free
(
tmp
);
}
free
(
list
->
pos
);
}
int
array_pop
(
element
*
array
)
{
element
*
tmp
=
array
;
array
=
array
->
next
;
int
value
=
tmp
->
data
;
return
value
;
}
void
print_list
(
list
*
list
)
{
list
->
pos
=
list
->
head
;
while
(
list
->
pos
->
next
!=
NULL
)
{
printf
(
"%i "
,
list
->
pos
->
data
);
list
->
pos
=
list
->
pos
->
next
;
}
printf
(
"%i "
,
list
->
pos
->
data
);
}
int
read_list
(
list
*
list
)
{
list
->
pos
=
list
->
head
;
if
(
list
->
pos
->
next
!=
NULL
)
{
list
->
pos
=
list
->
pos
->
next
;
}
return
list
->
pos
->
data
;
}
int
main
()
{
printf
(
"Entrez la liste
\n
"
);
int
list_length1
;
scanf
(
"%i"
,
&
list_length1
);
list
list1
;
for
(
int
i
=
0
;
i
<
list_length1
;
i
++
)
{
element
*
elem
=
malloc
(
sizeof
(
*
elem
));
if
(
list1
.
head
!=
NULL
)
{
elem
->
next
=
list1
.
head
;
}
else
{
elem
->
next
=
NULL
;
}
int
value
;
scanf
(
"%i"
,
&
value
);
elem
->
data
=
value
;
list1
.
head
=
elem
;
}
printf
(
"Entrez la liste
\n
"
);
int
list_length2
;
scanf
(
"%i"
,
&
list_length2
);
list
list2
;
for
(
int
i
=
0
;
i
<
list_length2
;
i
++
)
{
element
*
elem
=
malloc
(
sizeof
(
*
elem
));
if
(
list2
.
head
!=
NULL
)
{
elem
->
next
=
list2
.
head
;
}
else
{
elem
->
next
=
NULL
;
}
int
value
;
scanf
(
"%i"
,
&
value
);
elem
->
data
=
value
;
list2
.
head
=
elem
;
}
int
values
[
list_length1
+
list_length2
];
for
(
int
i
=
0
;
i
<
list_length1
;
i
++
)
{
values
[
i
]
=
read_list
(
&
list1
);
}
for
(
int
i
=
list_length1
;
i
<
list_length2
+
list_length1
;
i
++
)
{
values
[
i
]
=
read_list
(
&
list2
);
}
printf
(
"intersection :
\n
"
);
for
(
int
i
=
0
;
i
<
list_length1
+
list_length2
;
i
++
)
{
printf
(
"%i"
,
values
[
i
]);
}
printf
(
"
\n
"
);
// list sorted_list_intersection;
// list1.pos = list1.head;
// for(int i = 0; i < list_length1; i++)
// {
// int value = list1.pos->data;
// if(list1.pos->next != NULL)
// {
// list1.pos = list1.pos->next;
// }
// element *elem = malloc(sizeof(*elem));
// if(sorted_list_intersection.head != NULL)
// {
// sorted_list_intersection.pos = sorted_list_intersection.head;
// while(sorted_list_intersection.pos->next != NULL && value > sorted_list_intersection.pos->data)
// {
// sorted_list_intersection.pos = sorted_list_intersection.pos->next;
// }
// if(sorted_list_intersection.pos->next != NULL)
// {
// element *tmp = sorted_list_intersection.pos->next;
// sorted_list_intersection.pos->next = elem;
// elem->next = tmp;
// }
// else
// {
// sorted_list_intersection.pos->next = elem;
// }
// }
// else
// {
// elem->next = NULL;
// sorted_list_intersection.head = elem;
// }
// elem->data = value;
// }
print_list
(
&
list1
);
print_list
(
&
list2
);
// print_list(&sorted_list_intersection);
list_destroy
(
&
list1
);
list_destroy
(
&
list2
);
// list_destroy(&sorted_list_intersection);
// for(int i = 0; i < array_length1; i++)
// {
// printf("%i", array_pop(array1));
// }
// printf("%i", array_length1);
// free_array(array1);
}
This diff is collapsed.
Click to expand it.
exo3/exo3
deleted
100755 → 0
+
0
−
0
View file @
1b0d9c5b
File deleted
This diff is collapsed.
Click to expand it.
michael.divia
@michael.divia
·
1 year ago
Tu peux m'expliquer le backtracking ?
Tu peux m'expliquer le backtracking ?
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment