User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 391,671 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,027 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:

ASK about C++ stack

Join Date: Mar 2007
Posts: 2
Reputation: daphnie is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
daphnie daphnie is offline Offline
Newbie Poster

Re: ASK about C++ stack

  #2  
Mar 1st, 2007
I have just write out somrrthing like this

int main() {
stack<char> allwords;
char word;

while (cin >> word) {
if (word == '(')
{allwords.push(word);}
else
if (word == ')')
{allwords.pop();}
}

if (allwords.size() == 0)
{cout << "The stack is %d. It is balance!" << allwords.size() << endl;}
else
{cout << "Number of words = " << allwords.size() << endl;}


return 0;
}


So how can I count number of those braces??

Can you help me??
Reply With Quote  
All times are GMT -4. The time now is 2:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC