ex2 of stackandqueue