A and B use the same string of numbers to play the game. There are 15 games in total. In the beginning, these numbers are not strictly ascending. A removes one data. If the numbers are strictly ascending, a wins, otherwise, Party B will continue to remove the data. If the data is strictly in ascending order, Party B will win the game. Otherwise, Party A will delete the data again. Determine whether a wins or B wins based on 15 initial data records.
# Include <iostream> # include <list> using namespace STD; bool SUP (list <int> & L) // determine whether the condition is strictly ascending {If (L. size () = 1) {return true;} else {list <int >:: iterator iter1, iter2; iter1 = L. begin (); iter2 = L. begin (); ++ iter2; while (iter2! = L. end () {If (* iter1> = * iter2) {return false;} + + iter1; ++ iter2;} return true ;}} bool func (list <int> L) {list <int>: iterator ITER; For (iter = L. begin (); iter! = L. end ();) // remove any one of the list to see if it can be strictly ascending {int temp = * ITER; L. erase (ITER ++); If (SUP (L) {return true;} l. insert (ITER, temp);} For (iter = L. begin (); iter! = L. end ();) // if any one is removed, it cannot be strictly ascending. If any one is removed, check whether Party B can win {int temp = * ITER; L. erase (ITER ++); If (! Func (L) // Party B cannot win, that is, Party A wins {return true;} l. insert (ITER, temp);} return false; // B wins in all cases} int main () {int Buf [] = {, 5 }; list <int> L; For (INT I = 0; I <sizeof (BUF)/sizeof (INT); I ++) {L. push_back (BUF [I]);} If (func (L) {cout <"true" <Endl ;} else {cout <"false" <Endl;} return 0 ;}