c++小问题帮我改改

来源:百度知道 编辑:UC知道 时间:2024/05/20 13:27:19
write a program that reads a sequence of integers of increasing size and prints the integers in decreasing order of size.Input terminates as soon as an integer that does not exceed its predecessor is read.The intgers are then printed in decreasing order.可用STL
#include<stack>
#include<iostream>
using namespace std;

int main()
{
double item;
stack<double>numbers;
cin>>item;
numbers.push(item);
cin>>item;
while(item>=numbers.top())
{
numbers.push(item);
cin>>item;
}
while(!numbers.empty()){
cout<<numbers.top()<<" ";
numbers.pop();
}
cout<<endl;
}这是我写的,怎么能改成一输入一个比前面小的数马上就输出呢?

write a program that reads a sequence of integers of increasing size and prints the integers in decreasing order of size.Input terminates as soon as an integer that does not exceed its predecessor is read.The intgers are then printed in decreasing order
写一段程序,读入一系列的递增的整数,并且按递减的顺序打印出来。当读入一个比他前面的数小的数的时候输入终止,整数按降序排列打印出来。
这和你的程序作的不是正合适么??
有什么问题?