Skip to content
Snippets Groups Projects
Commit 9bbd6f7a authored by jerome.maison's avatar jerome.maison
Browse files

exo2

parent 5f2b035e
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ LDFLAGS:=-lm ...@@ -8,7 +8,7 @@ LDFLAGS:=-lm
exo2: exo2.c exo2: exo2.c
$(CC) $(CFLAGS) -c $@ $^ $(LDFLAGS) $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
clean: clean:
rm -f *.o exo2 rm -f *.o exo2
#include <stdio.h>
#include <stdlib.h>
char fuse_tab(int s1, int s2, char *chain1, char *chaine2);
int main() {
int s1 = 8;
int s2 = 5;
char chaine1[s1];
chaine1[0] = 'O';
chaine1[1] = 'r';
chaine1[2] = 'e';
chaine1[3] = 's';
chaine1[4] = 't';
chaine1[5] = 'i';
chaine1[6] = 's';
chaine1[7] = '\0';
char chaine2[s2];
chaine2[0] = 'P';
chaine2[1] = 'a';
chaine2[2] = 'u';
chaine2[3] = 'l';
chaine2[4] = '\0';
char out_chaine[s1 + s2];
out_chaine[s1 + s2] = fuse_tab(8, 5, chaine1[8], chaine2[5]);
for(int i = 0; i < (s1 + s2); ++i){
printf("%c", out_chaine[i]);
}
}
char fuse_tab(int s1, int s2, char chaine1[s1], char chaine2[s2]){
int s;
if(s1 < s2){
s = s1;
}else{
s = s2;
}
char out_chaine[s1 + s2];
for(int i = 0; i < s; i += 2){
out_chaine[i] = chaine1[i];
out_chaine[i + 1] = chaine2[i];
}
return out_chaine[s1 + s2];
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment