コード例 #1
0
int main(){
    double value;

    // declare a queue & enqueue 10 numbers
    Dqueue queue;
    for (int i = 0; i < 10; i++){
        queue.enqueue(i);
    }

    cout << "printing queue" << endl;
    // as long as there are values on the queue, remove them and print them
    while (queue.dequeue(value)){
        cout << value << endl;
    }


    // declare a stack & push 10 numbers
    Dstack stack;
    for (int i = 0; i < 10; i++){
        stack.push(i);
    }

    cout << "printing stack" << endl;
    // as long as there are values on the stack, remove them and print them
    while (stack.pop(value)){
        cout << value << endl;
    }
}
コード例 #2
0
ファイル: reverse.cpp プロジェクト: jx63king/CSCI211
int main()
{
    double value;
    Dstack stack;

    // as long as there is input
    while (cin >> value)
      stack.push(value);
      
    // as long as the stack is not empty, pop numbers and print them
    while (!stack.empty())
      cout << stack.pop() << endl;

    return 0;
}
コード例 #3
0
ファイル: reverse.cpp プロジェクト: CSUChico-CSCI211/CSCI211
int main()
{
    double value;
    Dstack stack;

    // as long as there is input
    while (cin >> value)
      stack.push(value);
      
    cout << "There are " << stack.size() << " numbers in the stack." << endl;
    // as long as the stack is not empty, pop numbers and print them
    // pop return false if the pop failed
    while (stack.pop(value))
      cout << value << endl;
    cout << "There are " << stack.size() << " numbers in the stack." << endl;

    return 0;
}
コード例 #4
0
ファイル: reverse.cpp プロジェクト: Pithers/Class-Work
int main()
{
  double temp = 0;
  Dstack stack;
  
  while(cin >> temp)
  {
    stack.push(temp);
  }

  cout << "There are " << stack.size() << " numbers in the stack.\n";

  while(!stack.empty())
  {
    stack.pop(temp);
    cout << temp << endl;
  }

  cout << "There are " << stack.size() << " numbers in the stack.\n";
  
  return 0;
}