Problem finding error..

This is a discussion on Problem finding error.. within the C++ Programming forums, part of the General Programming Boards category; Hi, I'm new here.. sorry if this question is funny.i Got this question and answer online..i just want to study ...

  1. #1
    Registered User
    Join Date
    Jul 2013
    Location
    Malaysia
    Posts
    4

    Problem finding error..

    Hi,
    I'm new here.. sorry if this question is funny.i Got this question and answer online..i just want to study it..but when i'm try to compile it, the code got some errors...can anyone help?

    Consider the problem of recognizing whether a particular string is in the language:
    L = { w$w’: w is a possibly empty string of characters other than $, w’ = reverse(w) }.
    Write a C program to determining whether a given string is in L. You must apply stacks to solve this question.


    Output Sample 1:
    Input a string: ABC$CBA
    Result: The above string is in the language


    Output Sample 2:
    Input a string: ABCD$CB
    Result: The above string is not in the language

    Code:
    #include <iostream>
    #include <string>
    #include <stack>
    using namespace std;
    
    
    typedef char StackItemType;
    
    
    class Stack {
    
    
    private:
      stack<StackItemType> s;
    public:
      bool isEmpty() const {
          return s.empty();
      }
    
    
      void push(const StackItemType & v) {
        s.push(v);
      }
    
    
      void pop() {
        s.pop();
      }
    
    
      void pop(StackItemType & stackTop) {
        stackTop = s.top();
        s.pop();
      }
    
    
      void getTop(StackItemType & stackTop) {
        stackTop = s.top();
      }
    
    
      int size() {
        return s.size();
      }
    };
    
    
    // TODO(student9#9#): Write your code here
    // Begin Question
    bool isInTheLanguage(const string & input)
    {
    
    
    
    
    
    
    }
    // End Question
    
    
    int main(int argc, char* argv[])
    {
        string input;
        bool inLanguage = false;
    
    
        cout << "Input a string: ";
        cin >> input;
    
    
        inLanguage = isInTheLanguage(input);
    
    
        if (inLanguage)
        {
            cout << "Result: The above string is in the language" << endl;
        }
        else {
            cout << "Result: The above string is not in the language" << endl;
        }
    
    
        system("PAUSE");
        return 0;
    }
    Last edited by azrey86; 07-08-2013 at 03:33 AM. Reason: forgot the question..

  2. #2
    Registered User
    Join Date
    Nov 2011
    Posts
    84
    Needs to be posted in C++ section, this is 'C'.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,456
    Indeed; moved to C++ programming forum.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Jul 2013
    Location
    Malaysia
    Posts
    4
    Quote Originally Posted by laserlight View Post
    Indeed; moved to C++ programming forum.
    Thanks Laserlight..i thougt this is about C.. base on the question..thanks..

  5. #5
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,187
    i thougt this is about C.. base on the question..thanks..
    O_o

    So, this is obviously homework, but I still have a question despite having no intention to provide a solution.

    The question: are you supposed to be writing C or C++?

    Soma
    “Often out of periods of losing come the greatest strivings toward a new winning streak.” -- Fred Rogers
    “Salem Was Wrong!” -- Pedant Necromancer

  6. #6
    Registered User
    Join Date
    Jul 2013
    Location
    Malaysia
    Posts
    4
    Quote Originally Posted by phantomotap View Post
    O_o

    So, this is obviously homework, but I still have a question despite having no intention to provide a solution.

    The question: are you supposed to be writing C or C++?

    Soma
    i'm sorry this not homework.i got it from internet..just try to compile but it got some errors..
    here the links that i got this -->>
    https://www.google.com.my/url?sa=t&r...rGIs1KAmF4Z2OA
    Last edited by azrey86; 07-08-2013 at 05:32 AM. Reason: typing error

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,456
    If you don't know if it is C or C++, then perhaps you are jumping the gun. I suggest that you forget about this exercise for the time being and learn C or C++, whichever one you choose.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Jul 2013
    Location
    Malaysia
    Posts
    4
    thanks for all...all of u are very nice ..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please help me finding the error... :(
    By fredsilvester93 in forum C Programming
    Replies: 4
    Last Post: 01-04-2012, 12:15 AM
  2. new to C & need help finding parse error
    By dsemel in forum C Programming
    Replies: 3
    Last Post: 02-10-2011, 12:42 AM
  3. Help finding the error
    By C++Noob316 in forum C++ Programming
    Replies: 6
    Last Post: 03-13-2009, 01:16 PM
  4. Need help finding error
    By chorney in forum C++ Programming
    Replies: 13
    Last Post: 01-14-2007, 11:16 PM
  5. Finding out a Parse error
    By Ziionyx in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2003, 12:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21