Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithmie
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
mathias.catala
Algorithmie
Commits
642ec133
Commit
642ec133
authored
1 year ago
by
mathias.catala
Browse files
Options
Downloads
Patches
Plain Diff
"yes"
parent
e1065462
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
myTP/exos/dilatation.c
+83
-0
83 additions, 0 deletions
myTP/exos/dilatation.c
myTP/exos/exo1
+0
-0
0 additions, 0 deletions
myTP/exos/exo1
myTP/exos/exo1.c
+6
-13
6 additions, 13 deletions
myTP/exos/exo1.c
myTP/test.c
+0
-10
0 additions, 10 deletions
myTP/test.c
with
89 additions
and
23 deletions
myTP/exos/dilatation.c
0 → 100644
+
83
−
0
View file @
642ec133
#include
<stdio.h>
#include
<stdlib.h>
int
get_max
(
int
n
,
const
int
*
tab
)
{
int
max
=
tab
[
0
];
for
(
int
i
=
1
;
i
<
n
;
i
++
)
{
if
(
tab
[
i
]
>
max
)
{
max
=
tab
[
i
];
}
}
return
max
;
}
int
**
dilatation
(
int
m
,
int
n
,
const
int
**
tab
)
{
int
**
res
=
(
int
**
)
malloc
(
m
*
sizeof
(
int
*
));
for
(
int
i
=
0
;
i
<
m
;
i
++
)
{
res
[
i
]
=
(
int
*
)
malloc
(
n
*
sizeof
(
int
));
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
int
max
[
5
];
int
k
=
0
;
max
[
k
]
=
tab
[
i
][
j
];
k
+=
1
;
if
(
i
>
0
)
{
max
[
k
++
]
=
tab
[
i
-
1
][
j
];
}
if
(
i
<
m
-
1
)
{
max
[
k
++
]
=
tab
[
i
+
1
][
j
];
}
if
(
j
>
0
)
{
max
[
k
++
]
=
tab
[
i
][
j
-
1
];
}
if
(
j
<
n
-
1
)
{
max
[
k
++
]
=
tab
[
i
][
j
+
1
];
}
res
[
i
][
j
]
=
get_max
(
k
,
max
);
}
}
return
res
;
}
void
print_tab
(
int
m
,
int
n
,
const
int
**
tab
)
{
for
(
int
i
=
0
;
i
<
m
;
i
++
)
{
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
int
debug
=
tab
[
i
][
j
];
printf
(
"%d "
,
tab
[
i
][
j
]);
}
printf
(
"
\n
"
);
}
printf
(
"
\n
"
);
}
int
**
init_array
(
int
m
,
int
n
)
{
int
**
res
=
(
int
**
)
malloc
(
m
*
sizeof
(
int
*
));
int
k
=
1
;
for
(
int
i
=
0
;
i
<
m
;
i
++
)
{
res
[
i
]
=
(
int
*
)
malloc
(
n
*
sizeof
(
int
));
for
(
int
j
=
0
;
j
<
n
;
j
++
)
{
res
[
i
][
j
]
=
k
++
;
}
}
return
res
;
}
int
main
()
{
int
m
=
5
,
n
=
5
;
int
**
tab
=
init_array
(
m
,
n
);
print_tab
(
m
,
n
,
(
const
int
**
)
tab
);
int
**
res
=
dilatation
(
m
,
n
,
(
const
int
**
)
tab
);
print_tab
(
m
,
n
,
(
const
int
**
)
res
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
myTP/exos/exo1
+
0
−
0
View file @
642ec133
No preview for this file type
This diff is collapsed.
Click to expand it.
myTP/exos/exo1.c
+
6
−
13
View file @
642ec133
...
...
@@ -15,14 +15,14 @@ void insertionSort(int n, int tab[]);
int
main
(){
int
i
;
int
arr
[]
=
{
64
,
34
,
25
,
12
,
22
,
11
,
90
};
int
arr
[]
=
{
64
,
34
,
25
,
12
,
22
,
11
,
1
};
int
n
=
sizeof
(
arr
)
/
sizeof
(
arr
[
0
]);
for
(
i
=
0
;
i
<
n
;
i
++
)
printf
(
"%d "
,
arr
[
i
]);
//
bubbleSort(n,arr);
insertionSort
(
n
,
arr
);
bubbleSort
(
n
,
arr
);
//
insertionSort(n,arr);
printf
(
"
\n
Sorted array:
\n
"
);
for
(
i
=
0
;
i
<
n
;
i
++
)
...
...
@@ -147,8 +147,7 @@ void bubbleSort(int n, int tab[]){
void
insertionSort
(
int
n
,
int
tab
[]){
int
i
;
bool
swapped
;
for
(
i
=
0
;
i
<
n
-
1
;
i
++
){
int
tmp
=
tab
[
i
];
...
...
@@ -158,14 +157,8 @@ void insertionSort(int n, int tab[]){
tab
[
pos
]
=
tab
[
pos
-
1
];
pos
-=
1
;
}
tab
[
pos
]
=
tmp
;
tab
[
pos
]
=
tmp
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
myTP/test.c
+
0
−
10
View file @
642ec133
...
...
@@ -2,12 +2,8 @@
#include
<stdio.h>
void
recurse
(
int
n
){
printf
(
"%d"
,
n
%
2
);
if
(
n
/
2
!=
0
){
...
...
@@ -21,17 +17,11 @@ void recurse(int n){
int
fibonacci
(
int
i
){
if
(
i
>
1
){
return
printf
(
"fibo: %u
\n
"
,
fibonacci
(
i
-
1
)
+
fibonacci
(
i
-
2
));
}
return
i
;
}
...
...
This diff is collapsed.
Click to expand it.
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