摘要: 题目描述:用两个栈来实现一个队列,完成队列的Push和Pop操作。队列中的元素为int类型。输入:每个输入文件包含一个测试样例。对于每个测试样例,第一行输入一个n(1=0)2. POP 从队列中pop一个数。输出:对应每个测试案例,打印所有pop操作中从队列pop中的数字。如果执行pop操作时,队列为空,则打印-1。样例输入:3PUSH 10POPPOP样例输出:10-1题解:应该是考察STL栈应用的一道面试题,还有一点小技巧,不要用两个水杯倒来倒去(如图,明显错误做法)。用一个水杯倒就可以了。代码:C的简洁 && C++的优雅。C代码:#include #include #i 阅读全文
posted @ 2014-02-09 19:27 Levi.duan 阅读(826) 评论(0) 推荐(1)
摘要: The ProblemFootball the most popular sport in the world (americans insist to call it "Soccer",but we will call it "Football"). As everyone knows, Brasil is the country that have mostWorld Cup titles (four of them: 1958, 1962, 1970 and 1994). As our national tournament have many t 阅读全文
posted @ 2014-02-09 16:41 Levi.duan 阅读(590) 评论(0) 推荐(0)