ZadatakS14.

#include <iostream>

using namespace std;

int main()
{
int d,poc,kraj,p,k,i,max;
string s;
cout<<„Unesi recenicu“<<endl;
getline(cin, s);
d= s.size(), max=0, p, k;
poc=0,kraj=0;
for (int i=0; i < d-1; i++)
{if (s[i]==’ ‘ && s[i+1]!=’ ‘) poc=i+1;
if (s[i]!=’ ‘ && s[i+1]==’ ‘) kraj=i;
if (i+1==d-1 && s[i+1]!=’ ‘) kraj =i+1;
if (kraj – poc > max) {max=kraj-poc; p=poc;k=kraj;}
}
for ( i=p;i<=k;i++)
cout << s[i];
cout << endl;
return 0;
}

Advertisements