Advertisement
Benlahbib_Abdessamad

Untitled

May 6th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. #define Max 100
  6.  
  7. void expansee(char chaine[Max],int number)
  8. {
  9.     if(number>0)
  10.     {
  11.         char * string=(char*)malloc(sizeof(char)*strlen(chaine) * 3);
  12.         int i,counter=0;
  13.         for(i=0;i<strlen(chaine);i++)
  14.         {
  15.             if(chaine[i]=='a')
  16.             {
  17.                 string[counter]='b';counter++;  string[counter]='c';  counter++;
  18.             }
  19.             else if(chaine[i]=='b')
  20.             {
  21.                 string[counter]='c';counter++;  string[counter]='a';  counter++;
  22.             }
  23.             else if(chaine[i]=='c')
  24.             {
  25.                 string[counter]='a';counter++;
  26.             }
  27.             else
  28.             {
  29.                 break;
  30.             }
  31.         }
  32.         string[counter]='\0';
  33.         printf("le resultat est : %s \n",string);
  34.         return expansee(string,number-1);
  35.     }
  36. }
  37.  
  38.  
  39.  
  40. int main()
  41. {
  42.     expansee("a",5);
  43.     getchar();
  44.     return 1;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement