SelinD

v80s2e5

Mar 4th, 2019
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstring>
  3. using namespace std;
  4. char s[21], v[]="aeiou",aux;
  5. int main()
  6. {
  7. int pv=-1,pc=-1,i;
  8. cin.getline(s,21);
  9. for(i=0; i<strlen(s); i++)
  10. {
  11. if(strchr(v,s[i])==0)
  12. {
  13. pc=i;
  14. break;
  15. }
  16. }
  17. for(i=strlen(s)-1; i>0; i--)
  18. {
  19. if(strchr(v,s[i])!=0)
  20. {
  21. pv=i;
  22. break;
  23. }
  24. }
  25. if(pv!=-1 && pc!=-1)
  26. {
  27. aux=s[pv];
  28. s[pv]=s[pc];
  29. s[pc]=aux;
  30. cout<<s;
  31. }
  32. else cout<<"nu exista";
  33. }
Add Comment
Please, Sign In to add comment