Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Prog_C
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nathan Accart
Prog_C
Commits
ee7c5ba9
Commit
ee7c5ba9
authored
3 years ago
by
nathan accart
Browse files
Options
Downloads
Patches
Plain Diff
ajout TP03
parent
8c37003e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
TP03/Exo1
+0
-0
0 additions, 0 deletions
TP03/Exo1
TP03/Exo1.c
+67
-0
67 additions, 0 deletions
TP03/Exo1.c
TP03/Exo2
+0
-0
0 additions, 0 deletions
TP03/Exo2
TP03/Exo2.c
+34
-0
34 additions, 0 deletions
TP03/Exo2.c
with
101 additions
and
0 deletions
TP03/Exo1
0 → 100755
+
0
−
0
View file @
ee7c5ba9
File added
This diff is collapsed.
Click to expand it.
TP03/Exo1.c
0 → 100644
+
67
−
0
View file @
ee7c5ba9
#include
<stdio.h>
#include
<stdlib.h>
char
*
nouveau_tableau
(
int
taille
);
void
initialise_tableau
(
char
*
tableau
,
int
taille
,
char
car
);
void
affiche_tableau
(
char
*
tableau
,
int
taille
);
void
liberation_du_tableau
(
char
*
tableau
);
void
place_dans_tableau
(
char
*
tableau
,
int
taille
,
int
indice
,
char
car
);
char
lecture_du_tableau
(
char
*
tableau
,
int
taille
,
int
indice
);
int
main
(
void
){
char
*
tab
=
nouveau_tableau
(
4
);
initialise_tableau
(
tab
,
4
,
'a'
);
affiche_tableau
(
tab
,
4
);
//liberation_du_tableau (tab);
//affiche_tableau (tab,4);
place_dans_tableau
(
tab
,
4
,
2
,
'z'
);
affiche_tableau
(
tab
,
4
);
lecture_du_tableau
(
tab
,
4
,
21
);
}
char
*
nouveau_tableau
(
int
taille
){
char
*
pt
;
pt
=
malloc
(
taille
*
sizeof
(
char
));
return
pt
;
}
void
initialise_tableau
(
char
*
tableau
,
int
taille
,
char
car
){
for
(
int
i
=
0
;
i
<
taille
;
i
++
){
tableau
[
i
]
=
'a'
+
i
;
}
tableau
[
2
]
=
'e'
;
}
void
affiche_tableau
(
char
*
tableau
,
int
taille
){
printf
(
"
\n
"
);
for
(
int
i
=
0
;
i
<
taille
;
i
++
){
printf
(
" %c"
,
tableau
[
i
]);
}
printf
(
"
\n\n
"
);
}
void
liberation_du_tableau
(
char
*
tableau
){
free
(
tableau
);
printf
(
"Le tablo conti1%c"
,
*
tableau
);
}
void
place_dans_tableau
(
char
*
tableau
,
int
taille
,
int
indice
,
char
car
){
tableau
[
indice
]
=
car
;
if
(
indice
>
taille
||
indice
<
taille
){
printf
(
"Erreur...Erreur...Erreur"
);
}
}
char
lecture_du_tableau
(
char
*
tableau
,
int
taille
,
int
indice
){
char
car
;
if
(
indice
>
taille
||
indice
<
0
){
tableau
[
indice
]
=
'\0'
;
printf
(
"Erreur...Erreur...Erreur"
);
car
=
'\0'
;
}
else
{
car
=
tableau
[
indice
];
printf
(
"Char : %c"
,
car
);
}
return
car
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
TP03/Exo2
0 → 100755
+
0
−
0
View file @
ee7c5ba9
File added
This diff is collapsed.
Click to expand it.
TP03/Exo2.c
0 → 100644
+
34
−
0
View file @
ee7c5ba9
#include
<stdio.h>
#include
<stdlib.h>
void
initialiser_tableau
(
char
*
tab
,
int
taille
);
void
affiche_tableau
(
char
*
tableau
,
int
taille
);
typedef
struct
{
char
*
tableau
;
int
taille
;
}
super_tableau_t
;
int
main
(
void
){
super_tableau_t
*
super_tab
=
malloc
(
sizeof
(
super_tableau_t
));
super_tab
->
taille
=
4
;
super_tab
->
tableau
=
malloc
(
super_tab
->
taille
*
sizeof
(
char
));
initialiser_tableau
(
super_tab
->
tableau
,
super_tab
->
taille
);
affiche_tableau
(
super_tab
->
tableau
,
super_tab
->
taille
);
}
void
initialiser_tableau
(
char
*
tab
,
int
taille
){
tab
[
0
]
=
'a'
;
for
(
int
i
=
0
;
i
<
taille
;
i
++
){
tab
[
i
]
=
tab
[
0
]
+
i
;
}
}
void
affiche_tableau
(
char
*
tableau
,
int
taille
){
printf
(
"
\n
"
);
for
(
int
i
=
0
;
i
<
taille
;
i
++
){
printf
(
" %c"
,
tableau
[
i
]);
}
printf
(
"
\n\n
"
);
}
\ No newline at end of file
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