Advertisement
nicuvlad76

Untitled

Nov 24th, 2020
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     char *p,s[256],cuv[55][20],aux[256];
  8.     cin.get(s,256);
  9.     int nr=0,i,j;
  10.     for(i=0;s[i];++i)
  11.         if((s[i]==' '&&s[i-1]!=' ')||(s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z'))
  12.             aux[nr++]=s[i];
  13.     aux[nr]=NULL;
  14.     strcpy(s,aux);
  15.     p=strtok(s," ");
  16.     nr=0;
  17.     while(p)
  18.     {
  19.         strcpy(cuv[++nr],p);
  20.         p=strtok(NULL," ");
  21.     }
  22.     for(i=1;i<=nr/2;++i)
  23.         cout<<cuv[i]<<'\n'<<cuv[nr-i+1]<<'\n';
  24.     if(nr%2)cout<<cuv[nr/2+1];
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement