Cod sursa(job #363439)

Utilizator APOCALYPTODragos APOCALYPTO Data 13 noiembrie 2009 10:49:08
Problema Floyd-Warshall/Roy-Floyd Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.48 kb

#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;
}