Pagini recente » Cod sursa (job #1338557) | Cod sursa (job #2204361) | Cod sursa (job #2577476) | Cod sursa (job #1799065) | Cod sursa (job #2756293)
#include <iostream>
#include <fstream>
using namespace std;
int nr_numere,numar,maxim=-1,op;
int main()
{
ifstream fin("operatii.in");
ofstream fout("operatii.out");
fin>>nr_numere;
while(nr_numere--)
{
fin>>numar;
if(numar!=0)
{
maxim=max(maxim,numar);
}
else
{
if(maxim>0)
{
op+=maxim;
}
maxim=-1;
}
}
if(maxim>0)
{
op+=maxim;
}
fout<<op<<'\n';
fout.close();
}