Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- char cuv[256][256];
- int LitD[256],Sp[256];
- bool cuvant(int i)
- {
- bool ok=false;
- for(int j=0;j<(int)strlen(cuv[i]);++j)
- if(isalpha(cuv[i][j]))
- {
- ok=true;
- break;
- }
- return ok;
- }
- void invers(int i)
- {
- if(cuvant(i))
- for(int j=0;j<LitD[i]/2;++j)
- swap(cuv[i][j],cuv[i][LitD[i]-1-j]);
- }
- int main()
- {
- char s[256],*p,separator[]=" ";
- cin.getline(s,256);
- int n=0,k=0;
- while(k<(int)strlen(s))
- {
- if(s[k]==' ')
- {
- Sp[n]=1;
- while(s[++k]==' ')
- ++Sp[n];
- ++n;
- }
- ++k;
- }
- p=s;
- p=strtok(p,separator);
- int MAX=0;
- n=0;
- while(p)
- {
- strcpy(cuv[n],p);
- if(cuvant(n))
- LitD[n]=strlen(cuv[n]);
- else
- LitD[n]=0;
- if(LitD[n]>MAX)
- MAX=LitD[n];
- ++n,p=strtok(NULL,separator);
- }
- for(int i=0;i<n;++i)
- {
- if(LitD[i]==MAX)
- invers(i);
- if(s[0]==' ')
- {
- for(int k=1;k<=Sp[i];++k)
- cout<<' ';
- cout<<cuv[i];
- }
- else
- {
- cout<<cuv[i];
- for(int k=1;k<=Sp[i];++k)
- cout<<' ';
- }
- }
- cout<<'\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement