Advertisement
Cinestra

Double a

Jan 13th, 2023
1,062
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. void double_a(char string[], char result[])
  6. {
  7.     int counter = 0;
  8.  
  9.     for (int i = 0; i < strlen(string); i++)
  10.     {
  11.         if (string[i] == 'a')
  12.         {
  13.             result[counter] = 'a';
  14.             result[counter + 1] = 'a';
  15.             counter += 2;
  16.         }
  17.  
  18.         else
  19.         {
  20.             result[counter] = string[i];
  21.             counter++;
  22.         }
  23.     }
  24.  
  25.     result[counter] = 0;
  26. }
  27.  
  28. int main()
  29. {
  30.     char base[30] = "Yoona eats flowers";
  31.     char new_base[30];
  32.     double_a(base, new_base);
  33.     cout << new_base;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement