CS计算机代考程序代写 // StackTest.cpp

// StackTest.cpp
// normal comments here – not doxygen comments
// Tests Stack classes
//
// Nicola Ritter
// modified smr
//
//
//——————————————————–

#include
#include
#include “Stack.h”
using namespace std;

//——————————————————–

typedef Stack CharStack;

//——————————————————–

void Input (string &str);
void Reverse (const string &str, CharStack &temp);
void Output (CharStack &temp);

//——————————————————–

int main()
{
string str;
CharStack temp;

Input (str);
Reverse (str, temp); // check lecture material, notes at the bottom and refactor
Output (temp);

cout << endl; return 0; } //-------------------------------------------------------- void Input (string &str) { cout << "Enter a string, then press : “;
getline(cin,str);
}

//——————————————————–

void Reverse (const string &str, CharStack &temp)
{
bool okay = true;
for (unsigned index = 0; index < str.length() && okay; index++) { okay = temp.Push(str[index]); } } //-------------------------------------------------------- void Output (CharStack &temp) { bool okay; char ch; cout << "Your string reversed is: "; okay = temp.Pop(ch); while (okay) { cout << ch; okay = temp.Pop(ch); } cout << endl; } //--------------------------------------------------------