Pagini recente » Cod sursa (job #1104622) | Cod sursa (job #116997) | Cod sursa (job #1485851) | Cod sursa (job #704148) | 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();
}