69,373
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <Stack>
using namespace std;
typedef struct
{
int x;
int y;
}element;
void main()
{
stack<double> s;
for( int i=0; i < 10; i++ )
s.push(i);
while(!s.empty())
{
printf("%lf\n",s.top());
s.pop();
}
cout << "This stack has a size of " << s.size() << endl;
}
#include <iostream>
#include <stack>
struct element_t
{
int x;
int y;
};
int main ()
{
std::stack<element_t> s;
for(int i = 0; i != 10; ++i)
{
s.push(element_t{i,i+1});
}
while (!s.empty())
{
element_t const& e = s.top();
printf("%d %d\n",e.x,e.y);
s.pop();
}
std::cout << "This stack has a size of " << s.size() << std::endl;
}
ps. 这是 c++ 程序,不是 c 程序。