![]() |
|
#1
|
|||
|
|||
Reverse output for a StackHi everyone, I've been taking a class on cprogramming and have been successful up thus far. I am now learning about stacks and am having tremendous problems. I've written a program that will calculate the prime factors of numbers. The only problem is that I needed to reverse the output as show in the example below
e.g. Prime factors of # 1 2 3 4 need printout to read 4 3 2 1 I understand the concept in which the output will first be stored in an array [1,2,3,4] but am not entirely sure on how to retreive it without making the program really long. I know about pop functions but have only used this with push empty and full functions in class. I am just having problems on trying to figure out how to implement it here. I've tested my prime factorization program by itself and I know it works but when I try to integrate it into the stack I get numerous errors and I am not sure if I am on the right track Please let me know if you have any suggestions. I feel as if I am close but am started to get frustrated because it feels as if I am missing something small Any help will be greatly appreciated Thanks in advance Sean CPP / C++ / C Code:
Last edited by admin : 06-Jul-2004 at 02:23.
Reason: Please insert [c] & [/c] tags between your example C codes
|
|
#2
|
|||
|
|||
Prime factor code (by itself)Hi this is a copy of my prime factorization code before I implement the stack. Once I implement the stack I begin running into errors
CPP / C++ / C Code:
Last edited by admin : 06-Jul-2004 at 02:24.
|
|
#3
|
||||
|
||||
|
Quote:
You have an array with the following values: [1,2,3,4] You probably have a variable that has the value 4 (the next empty space in the above array), which I will call nxt. If this is so, then simply: CPP / C++ / C Code:
__________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams Last edited by admin : 06-Jul-2004 at 02:24.
|
Recent GIDBlog
Stupid Management Policies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| IP tables | rogermark100 | C Programming Language | 6 | 18-Apr-2004 08:22 |
| using vector or array | oshiotse | C++ Forum | 4 | 16-Apr-2004 11:59 |
| Re: Piping and Redirection | WaltP | C Programming Language | 1 | 11-Apr-2004 09:01 |
| urgent: problem + output filters | jack | Apache Web Server Forum | 0 | 04-Feb-2004 23:32 |
| articles -> output | Allowee | Learning Journal by J de Silva | 1 | 05-Jun-2003 20:47 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The