Advertisement
halexandru11

var 39 s2 ex5

Dec 3rd, 2020
71
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. void rev(char s[]) {
  7.     int n = (int) strlen(s);
  8.     for(int i = 0; i < n/2; ++i) {
  9.         char c = s[i];
  10.         s[i] = s[n-1-i];
  11.         s[n-1-i] = c;
  12.     }
  13. }
  14.  
  15. int main() {
  16.     char s[256];
  17.     cin.get(s, 255);
  18.     cin.get();
  19.     int n = (int) strlen(s);
  20.     char t[256] = "";
  21.     char *p = strtok(s, " ");
  22.     while(p) {
  23.         if(strchr("aeiou", *p)) {
  24.             rev(p);
  25.         }
  26.         strcat(t, p);
  27.         strcat(t, " ");
  28.         p = strtok(NULL, " ");
  29.     }
  30.     strcpy(s, t);
  31.     cout << s;
  32. }
  33.  
Advertisement
RAW Paste Data Copied
Advertisement