实验一 栈及队列的应用.docVIP

  • 5
  • 0
  • 约4.48千字
  • 约 10页
  • 2018-09-14 发布于湖北
  • 举报
实验一 栈和队列的应用 一、实验目的 1、掌握栈的编写和应用 2、掌握队列的编写和应用 二、实验内容 1、分别使用STL中的栈和自己编写的栈类,实现序列的反转 (1)简单修改下面代码,实现使用STL中的栈进行序列的反转,编译运行 #include stack int main( ) /* Pre: The user supplies an integer n and n decimal numbers. Post: The numbers are printed in reverse order. Uses: The STL class stack and its methods */ { int n; double item; stackdouble numbers; // declares and initializes a stack of numbers cout Type in an integer n followed by n decimal numbers. endl The numbers will be printed in reverse order. endl; cin n; for (int i = 0; i n; i++) { cin item; numbers.push(item); } cout endl endl; whil

文档评论(0)

1亿VIP精品文档

相关文档