⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 数据结构与程序设计教材源码 数据结构与程序设计教材源码
💻 CPP
字号:
 
#include   "../../C/UTILITY.H"
 
typedef float Stack_entry;  //  The program will use stacks with float entries.
#include   "STACK.H"
 
#include   "../../C/UTILITY.CPP"
#include   "STACK.CPP"
 
main()
/*   
Pre:    The user supplies an integer n and n
floating point numbers.
Post:  The floating point numbers are printed in reverse order.
Uses:  The class Stack and its methods
 */

{
   int n;
   float item;
   Stack numbers;

   cout << " Type in an integer n followed by n floating point numbers.\n"
        << " The numbers will be printed in reverse order." << endl;
   cin  >> n;

   for (int i = 0; i < n; i++) {
      cin >> item;
      if (numbers.push(item) == overflow)
         cout << "\nThe stack is full." << endl;
   }

   cout << "\n\n";
   while (!numbers.empty()) {
      numbers.top(item);
      numbers.pop();
      cout << item << " ";
   }
   cout << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -