Professional Documents
Culture Documents
SDA Greedy
SDA Greedy
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
#include <iostream>
#include <stdlib.h>
//alt ex: alg lui dijkstra, grafuri
using namespace std;
#define NMAX 6
typedef struct{
int castig;
int greutate;
int index;
} obiect;
int indiciObiecteSelectate[NMAX];
57:
cout << "\tsatisfactie selectie " << eficienta[k] << endl;
58:
}
59: }
60:
61:
62:
63: int main(){
64:
obiect obiecte[NMAX] = {{4,5,1}, {2,3,2}, {3,4,3}, {1,2,4}, {5,6,5}, {6,7,
6}};
65:
int greutateRucsac, nrObiecte;
66:
67:
cout << "Introduceti numarul de obiecte, <" << NMAX << ": ";
68:
cin >> nrObiecte;
69:
70:
cout << "Introduceti greutatea rucsacului: ";
71:
cin >> greutateRucsac;
72:
73:
sortareInterschimbare(obiecte, nrObiecte);
74:
75:
umplereRucsac(obiecte, nrObiecte, greutateRucsac);
76:
77:
system("PAUSE");
78:
return 0;
79: }
80: