hi everyone
please tell me where did i go wrong,Thanks first.The question:
Write the function:
The string s and s1 must be the same size.String s1 should be come a reversed copy of string s.Ex:Code:Void reverse(char s[], char s1[]);
in put : My name is Jessica
out put: caissej si eman yM
Here what i have done so far:
PHP Code:#include <iostream>
#include <cstdlib>
class reverse{
public:
void reset() {top = EMPTY;}
void push(char c) { top++; s[top] =c;}
char pop() {return s[top--];}
char top_of() const { return s[top];}
bool empty() const {return (top ==EMPTY);}
bool full() const {return (top ==FULL);}
private:
enum {max_len =100, EMPTY =-1,FULL = max_len-1};
char s[max_len];
int top;
};
int main()
{
reverse s;
int i;
char s1;
cout << "enter a sentence",
cin >> s1;
s.reset();
while (s1[i] && !s.full())
s.push(s1[i++]);
while (!s.empty())
cout << s.pop();
cout << endl;
system("PAUSE");
return 0;
}




Reply With Quote