Advertisement
angelavaida27

Var80_SII_Ex5

Nov 17th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. char sir[101], aux, voc, con;
  5. int main ()
  6. {
  7.     int i, n, nr_voc=0, pozc, pozv;
  8.     cin>>sir;
  9.     n=strlen(sir);
  10.     for (i=0; i<=n; i++)
  11.     {
  12.         if (strchr("aeiouAEIOU", sir[i])==0)
  13.         {
  14.             con=sir[i];
  15.             break;
  16.         }
  17.     }
  18.     for (i=0; i<=n; i++)
  19.     {
  20.         if (strchr("aeiouAEIOU", sir[i])!=0)
  21.         {
  22.             voc=sir[i];
  23.             nr_voc++;
  24.         }
  25.     }
  26.     if (nr_voc==0 || nr_voc==n)
  27.     {
  28.         cout<<"IMPOSIBIL";
  29.     }
  30.     else
  31.     {
  32.         pozc=strchr(sir, con)-sir;
  33.         pozv=strchr(sir, voc)-sir;
  34.         aux=sir[pozc];
  35.         sir[pozc]=sir[pozv];
  36.         sir[pozv]=aux;
  37.         cout<<sir;
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement