|
|
вернуться в форумWhy would this fail test 1 #include<vector> #include<stack> #include<iostream> int main() { int noOfInstructions = 0; std::cin>> noOfInstructions; std::vector< std::stack< int > > myVectorOfStacks; myVectorOfStacks.reserve( 1001 ); for( int inx = 0; inx < 1001; ++inx ) { myVectorOfStacks.push_back( std::stack<int>() ); } char instruction[3]; int stackNumber = 0; int stackValue = 0;
for( int inx = 0; inx < noOfInstructions; ++inx ) { std::cin>> instruction; std::cin>> stackNumber; std::stack< int > & tempStack = myVectorOfStacks.at( stackNumber );
if( instruction[1] == 'U' ) { std::cin>> stackValue; tempStack.push( stackValue ); } else { std::cout<< tempStack.top()<< "\n"; tempStack.pop(); } } return 0; } |
|
|