Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,398 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,121 people online right now. Registration is fast and FREE... Join Now!




Programming in C++

 
Reply to this topicStart new topic

Programming in C++, Backtrack

k_ramadass
22 Sep, 2006 - 08:22 AM
Post #1

New D.I.C Head
*

Joined: 22 Sep, 2006
Posts: 1


My Contributions
Please , Can someone help me with this assignment.

Question:

Backtrack is one of the applications for stack data structure, in which you can trace back
the steps. Write a C program that allows you to read a set of integers. Every time you
read the negative integer, you must backtrack and print five integers which comes before
the negative integer.

Use stack data structure to solve this problem. Input/Read the integers and insert the
integers into stack (without printing it) until you found the negative integer. At this point,
you stop receiving/read input. Remove the five elements from the stack and print the
elements. After printing the five elements, continue receiving input/read data and insert
the items into the stack. When number 0 is entered, print the message of the remaining
items in the stack, and stop the program.


Test your program using the following data:
QUOTE

2 4 6 8 9 -1 2 3 4 5 6 7 8 9 -2 10 11 -3 2 4 6 8 9 0


This post has been edited by Dark_Nexus: 26 Sep, 2006 - 11:04 PM
User is offlineProfile CardPM
+Quote Post

Xing
RE: Programming In C++
22 Sep, 2006 - 09:17 AM
Post #2

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 2 times
Dream Kudos: 1575
My Contributions
Read the rules of forum. Period
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Programming In C++
22 Sep, 2006 - 05:02 PM
Post #3

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,230



Thanked: 40 times
Dream Kudos: 25
My Contributions
Xing is referring to the site's policy, by which we prefer to see some good faith effort on the part of the user before providing source code in the matter of academic assignments. If you could post the code you've written in an attempt to complete the assingment, our members would be pleased to help you.
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Programming In C++
22 Sep, 2006 - 10:12 PM
Post #4

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,935



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
Since I'm a First Year Engineering Student now, I can see that he's in the Second Year where they have a paper called "Data Structures".

Your assignment is very simple.
Use if constructs along with push and pop operations of the stack.
But I think you should've already thought of this.

So are you finding it difficult to write the push and pop operations?
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 03:01AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month