Pagini recente » Cod sursa (job #2926051) | Cod sursa (job #2664982) | Cod sursa (job #1191261) | Cod sursa (job #2042973) | Cod sursa (job #363439)
Cod sursa(job #363439)
#include<fstream>
#include<stdio.h>
#include<stack>
using namespace std;
int main()
{int n=10,i=0,cond=60,curent;
stack<int> stiva;
int v[100];
ifstream f("date.in");
f>>n>>cond;
for(i=1;i<=n-1;i++)
f>>v[i];
f.close();
stiva.push(1);
i=1;
curent+=v[i];
while(i<=n)
{ i++;
if(curent>=cond)
{curent=0;
stiva.push(i);
}
curent+=v[i];
}
stiva.pop();
while(!stiva.empty())
{printf("%d ",stiva.top());
stiva.pop();
}
return 0;
}