Pagini recente » Cod sursa (job #1941468) | Cod sursa (job #21058) | Cod sursa (job #1382048) | Cod sursa (job #103841) | Cod sursa (job #179320)
Cod sursa(job #179320)
#include<stdio.h>
#define nMAX 1000001
FILE*f;
long long n;
long long v[nMAX];
long long operatii;
void citeste()
{
f=fopen("operatii.in","r");
fscanf(f,"%;;d",&n);
int i;
for(i=1;i<=n;i++)
fscanf(f,"%lld",&v[i]);
fclose(f);
}
void rezolvare()
{
int i;
for(i=2;i<n;i++)
if(v[i]>v[i-1])
operatii=operatii+v[i]-v[i-1];
}
void afisare()
{
f=fopen("operatii.out","w");
fprintf(f,"%lld",operatii);
fclose(f);
}
int main ()
{
citeste();
rezolvare();
afisare();
return 0;
}