Found a particularly strange question: line 9 a [30] and there is no use array, but the result is not correct again after delete, excuse me somebody know how be to return a responsibility? C + + is indeed the most rubbish things, this problem is POJ1024Transportation #include #include #include #include #include using namespace std; Int n, p, t; Int ans. Int cap [8], a [30]. Struct order { Int the sta, des, num; Boolean operator & lt; (const order & amp; Pos) const { If (sta!=pos. The sta) return the sta & lt; Pos. The sta; The else return des & lt; Pos. Des; } } the orders [25];
Void search (int cur) { If (cur==t) { int sum=0; for (int i=0; i <=p; I++) The sum +=cap [I]; Ans=Max (ans, sum); return; } Int flag=1; For (int j=the orders [r]. Cur sta. J & lt; The orders (cur). Des; J++) { If (cap [j] + orders [r]. Cur num & gt; N) { Flag=0; break; } } If (flag==1) { For (int I=the orders [r]. Cur sta. i Cap [I] +=the orders [r]. Cur num. Search (cur + 1); For (int I=the orders [r]. Cur sta. i Cap -=[I] the orders [r]. Cur num. } Search (cur + 1); } Int main () { While (scanf_s (" % d % d % d ", & amp; N, & amp; P, & amp; T)!=EOF & amp; & (n | | p | | t)) { Ans=0; Memset (cap, 0, sizeof (cap)); for (int i=0; i Scanf_s (" % d % d % d ", & amp; The orders [I]. Sta, & amp; The orders [I]. Des, & amp; The orders [I] num); Sort (the orders, the orders + t); Search (0); Printf (" % d \ n ", ans); } return 0; }