Cod sursa(job #614283)

Utilizator GrimpowRadu Andrei Grimpow Data 5 octombrie 2011 22:07:03
Problema Operatii Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.33 kb
#include<fstream>
using namespace std;

int main()
{
    int x,y,s=0,n,i;
    ifstream f("operatii.in");
    ofstream g("operatii.out");
    f>>n;
    f>>y;
    for(i=1;i<n;i++)
    {
        f>>x;
        if(x<y)s+=y-x;
        y=x;
    }
    s+=x;
    g<<s;
    f.close();
    g.close();
    return 0;





}