Pagini recente » Cod sursa (job #1249077) | Cod sursa (job #1556267) | Cod sursa (job #319730) | Cod sursa (job #2076686) | Cod sursa (job #2305730)
#include <fstream>
using namespace std ;
ifstream f ("palm.in") ;
ofstream g ("palm.out") ;
int main ()
{
char c , a ; f >> a ;
int nrneg = 1 , nrcres = 1 , maxim = 1 ;
while ( f >> c )
{
if ( c > a ) nrcres ++ , nrneg = 1 ;
if ( c < a ) nrneg = max ( nrneg , nrcres ) + 1 , nrcres = 1 ;
if ( c == a) nrcres ++ , nrneg ++ ;
if ( nrneg > maxim ) maxim = nrneg ;
a = c ;
}
g << maxim ;
}