Programme 1:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int fin,debut=0,droite,gauche;
char mot[100],tmp;
printf(" donner un mot \n");
scanf("%s",mot);
fin=strlen(mot)-1;
for(droite=fin,gauche=debut;gauche<droite;gauche++,droite--){
tmp=mot[droite];
mot[droite]=mot[gauche];
mot[gauche]=tmp;
}
printf(" le mot miroir est %s \n",mot);
return 0;
}
L'execution de ce programme donne :
Programme 2: A deboguer
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int fin,debut,gauche;
char mot[100];
int main()
{
char tmp;
printf(" Donner un mot ");
scanf("%s",mot);
debut=0;
fin=strlen(mot);
for(gauche=debut;gauche<fin/2;gauche++){
tmp=mot[fin-gauche];
mot[fin-gauche]=mot[gauche];
mot[gauche]=tmp;
}
printf(" le mot miroir est %s \n",mot);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int fin,debut=0,droite,gauche;
char mot[100],tmp;
printf(" donner un mot \n");
scanf("%s",mot);
fin=strlen(mot)-1;
for(droite=fin,gauche=debut;gauche<droite;gauche++,droite--){
tmp=mot[droite];
mot[droite]=mot[gauche];
mot[gauche]=tmp;
}
printf(" le mot miroir est %s \n",mot);
return 0;
}
L'execution de ce programme donne :
Programme 2: A deboguer
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int fin,debut,gauche;
char mot[100];
int main()
{
char tmp;
printf(" Donner un mot ");
scanf("%s",mot);
debut=0;
fin=strlen(mot);
for(gauche=debut;gauche<fin/2;gauche++){
tmp=mot[fin-gauche];
mot[fin-gauche]=mot[gauche];
mot[gauche]=tmp;
}
printf(" le mot miroir est %s \n",mot);
return 0;
}