Push contents of both stacks in result
stack < int > res ; while ( ! s1 . empty ( ) ) { res . push ( s1 . top ( ) ) ; s1 . pop ( ) ; } while ( ! s2 . empty ( ) ) { res . push ( s2 . top ( ) ) ; s2 . pop ( ) ; }