Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- char cuv[301][301],s[301],*p,aux[300];
- int n,k;
- int main()
- {
- cin.getline(s,300);
- ///eliminat toate carcaterele diferite de spatiu si litere
- for(int i=0;s[i];i++)
- if((s[i]==' ' && s[i-1]!=' ')||(s[i]>='a'&& s[i]<='z') ||(s[i]>='A'&&s[i]<='Z'))
- aux[k++]=s[i];
- aux[k]=NULL;
- strcpy(s,aux);
- ///impartire in cuvinte
- p=strtok(s," ");
- while(p)
- {
- strcpy(cuv[++n],p);
- p=strtok(NULL," ");
- }
- ///afisare
- for(int i=1;i<=n/2;i++)
- cout<<cuv[i]<<'\n'<<cuv[n-i+1]<<'\n';
- if(n%2==1) cout<<cuv[n/2+1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment