nicuvlad76

Untitled

Nov 23rd, 2020
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. char cuv[301][301],s[301],*p,aux[300];
  4. int n,k;
  5.  
  6. int main()
  7. {
  8.    cin.getline(s,300);
  9.    ///eliminat toate carcaterele diferite de spatiu si litere
  10.    for(int 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[k++]=s[i];
  13.    aux[k]=NULL;
  14.    strcpy(s,aux);
  15.    ///impartire in cuvinte
  16.    p=strtok(s," ");
  17.    while(p)
  18.    {
  19.        strcpy(cuv[++n],p);
  20.        p=strtok(NULL," ");
  21.    }
  22.    ///afisare
  23.    for(int i=1;i<=n/2;i++)
  24.     cout<<cuv[i]<<'\n'<<cuv[n-i+1]<<'\n';
  25.    if(n%2==1) cout<<cuv[n/2+1];
  26.    return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment