ZadatakS31.

#include <cstring>
#include <iostream>

using namespace std;
int main( )
{ char ulaz[101];
cin>>ulaz;
for( int i = 1; ulaz[i] != ‘\0’; )
{ int ovce = 0, vukovi = 0;
while( ulaz[i] != ‘#’ )
{ if( ulaz[i] == ‘O’ ) ++ovce;
else if( ulaz[i] == ‘V’ ) ++vukovi;
else
{cout<<„Greska u unosu.“;
break;}
++i; }
cout<<„#“ ;
if( ovce > vukovi )
for( int j = 0; j < ovce; ++j )
cout<<„O“ ;
else
for( int j = 0; j < vukovi; ++j )
cout<<„V“; ++i; }
cout<<„#“ ;
cout<<endl;

return 0; }

Advertisements