Pagini recente » Cod sursa (job #1814311) | Cod sursa (job #2578584) | Cod sursa (job #2373105) | Cod sursa (job #2584337) | Cod sursa (job #880013)
Cod sursa(job #880013)
// operatii.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include "fstream"
using namespace std;
int main()
{
ifstream f("operatii.in");
ofstream g("operatii.out");
int nr;
f>>nr;
int elem;
int i,max=0,op=0;
for(i=0;i<nr;i++)
{
f>>elem;
if(elem>max)
max=elem;
if(elem==0)
{
op+=max;
max=0;
}
}
op+=max;
g<<op;
return 0;
}