Advertisement
nicuvlad76

Untitled

Dec 3rd, 2020
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. bool palindrom(char s[])
  4. {
  5.     int j=strlen(s)-1,i=0;
  6.     while(i<j)
  7.     {
  8.         if(s[i]!=s[j])return 0;
  9.         i++;j--;
  10.     }
  11.     return 1;
  12. }
  13. void oglindire(char s[])
  14. {
  15.     int n,i;
  16.     char aux;
  17.     n=strlen(s);
  18.     for(i=0;i<n/2;i++)
  19.        {
  20.            aux=s[i]; s[i]=s[n-i-1]; s[n-i-1]=aux;
  21.        }
  22. }
  23. int main()
  24. {
  25.     char s[101],*p,t[101]="";
  26.     int n=0,ok=0;
  27.     cin.getline(s,100);
  28.     p=strtok(s," ");
  29.     while(p)
  30.     {
  31.         if(strlen(p)%2==1)
  32.         {
  33.            if(palindrom(p)==0)
  34.                   {oglindire(p);ok=1;}
  35.         }
  36.         if(n!=0) strcat(t," ");
  37.         n++;
  38.         strcat(t,p);
  39.         p=strtok(NULL," ");
  40.     }
  41.     strcpy(s,t);
  42.     if(ok==1)cout<<s;
  43.     else cout<<"nu exista";
  44.     return 0;
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement