1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| #include<stdio.h>
#include<stdlib.h>
#define N 100
void sup(char mot[]);
void est_mot(char mot1[],char T[]);
int longeur(char mot1[]);
void egal(char mot2[] , char mot3[] );
void con(char mot2[] , char mot3[] );
main()
{
int k ;
char T[N] ;
char mot1[N];
char mot2[N];
char mot3[N];
printf("Contruire un Alphabet :\n");
fgets(T,N,stdin);
printf("Affichage de l'alphabet :\n%s",T);
printf("Saisir une chaine :\n");
fgets(mot1 , N , stdin);
sup(mot1);
est_mot(mot1,T);
printf("La longeur est %d\n",longeur(mot1));
printf("Saisir deux mot :\n");
printf("1 : ");
fgets(mot2 , N , stdin);
printf("2 : ");
fgets(mot3 , N , stdin);
sup(mot2);
sup(mot3);
egal( mot1 , mot2 );
con ( mot2 , mot3 );
getch();
}
void sup(char mot[])
{
int i ;
for( i=0 ; mot[i] != '\0' ; i++ );
mot[i-1] = '\0' ;
}
void est_mot(char mot1[],char T[])
{
int i , j , trouve , m=0 , n=0 ;
for( i=0 ; mot1[i] != '\0' ; i++ )
{
m++ ;
trouve = 0 ;
for( j=0 ; ((T[j] != '\0') && ( trouve == 0 )) ; j++ )
{
if( T[j] == mot1[i])
{
trouve = 1 ;
n++;
}
}
}
if( n == m)
printf("un mot\n");
else
printf("Pas un mot\n");
}
int longeur(char mot1[])
{
int i , m=0 ;
for( i=0 ; mot1[i] != '\0' ; i++ )
m++ ;
return m ;
}
void egal(char mot2[] , char mot3[] )
{
int m=0 , i ;
if( longeur(mot2) == longeur(mot3) )
{
for( i=0 ; i<longeur(mot3) ; i++ )
if( mot2[i] == mot3[i] )
m++;
if( longeur(mot3) == m )
printf("Indentique\n");
else
printf("Pas Indentique\n");
}
else
printf("Pas Indentique\n");
}
void con(char mot2[] , char mot3[] )
{
int i , m = longeur(mot2) ;
for(i=0 ; i < longeur(mot3) ; i++)
mot2[ m + i ] = mot3[i] ;
printf("%s\n",mot2);
} |
Partager