Pagini recente » Cod sursa (job #539767) | Cod sursa (job #329435) | Cod sursa (job #1425757) | Cod sursa (job #172737) | Cod sursa (job #1870457)
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
using namespace std;
int main()
{
int N, M, k, SumaInterogare, x, y, z;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
vector<double>myvector;
fin >> N >> M;
for (auto i = 0;i < N;i++)
{
fin >> k;
myvector.push_back(k);
}
for (auto i = 0;i < M;i++)
{
SumaInterogare = 0;
fin >> x >> y >> z;
if (x == 0)
myvector[y-1] = myvector[y-1] - z;
if (x == 1)
{
for (auto j = y - 1;j <= z - 1;j++)
SumaInterogare = SumaInterogare + myvector[j];
fout << SumaInterogare << endl;
}
}
}