题目:下面程序在执行过程中,若顺序输入十个整数: 1 2 3 4 5 6 7 8 9 10,其结果是什么。#include class stack;class node {int data;node *prev;public:node( int d, node *n ){data = d; prev = n;}friend class stack;};class stack {node *top;public:stack(){top = 0;}void push( int i ){node *n = new node( i, top ); top = n;}int pop(){node *t = top;if ( top ){top = top->prev; int c = t->data;delete t; return(c);}return(0);}};int main(){int c; stack s;for (int i = 0; i < 10; i++ ){std::cin >> c; s.push( c );}for (int i = 0; i < 10; i++ )std::cout << s.pop() << " ";std::cout << std::endl;}
答案:评论后可见此内容