#include<stack>
#include<iostream> //原文中没有此头文件using namespace std; int main(){ int n; double item; stack<double>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; while(!numbers.empty()) { cout<<numbers.top()<<""; numbers.pop(); } cout<<endl; return 0; //原文没有返回值}
此程序作用为输入n,再输入n个数,将这n个数排序。