| | |
pls check mainLoop() pseudocode for errors
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Hi All,
The following problem solution has given me fits!!!:mad: The problem states that a library records monthly book withdrawls, capturing the Library of Congress Number, Author and Title, for each month (sorted by the Library of Congress Number for each withdrawl). The initial problem required the merger of the January and Feburary files - which I was able to do without difficulty, but the follow-on problem required that any redundant records, regardless of file of origin, not be written to the merged file. I think I've gotten it, but I've gone through it so many times by now that I'm not sure if I really have it, or if I'm just chasing my tail trying to get a solution. Any help/pointers would be greatly appreciated!
FYI I've included code blocks for the overall program as well as each component module, but it's the mainLoop() module that I'm actually concerned about.
Program pseudocode
houseKeeping() module pseudocode mainLoop()pseudocode
finishUp() pseudocode
TIA
The following problem solution has given me fits!!!:mad: The problem states that a library records monthly book withdrawls, capturing the Library of Congress Number, Author and Title, for each month (sorted by the Library of Congress Number for each withdrawl). The initial problem required the merger of the January and Feburary files - which I was able to do without difficulty, but the follow-on problem required that any redundant records, regardless of file of origin, not be written to the merged file. I think I've gotten it, but I've gone through it so many times by now that I'm not sure if I really have it, or if I'm just chasing my tail trying to get a solution. Any help/pointers would be greatly appreciated!

FYI I've included code blocks for the overall program as well as each component module, but it's the mainLoop() module that I'm actually concerned about.
Program pseudocode
C Syntax (Toggle Plain Text)
comment: merge files "janResources" & "febResources" w/o writing duplicate comment: resource information (ie, ...LibCongressNum, ...Author & ...Title) comment: assignment operator is "=" and equals comparison operator is "==" Start perform houseKeeping() while bothAtEof == "N" then perform mainLoop() endwhile perform finishUp() Stop
houseKeeping() module pseudocode
C Syntax (Toggle Plain Text)
houseKeeping() declare variables: comment: file: "janResources" char janLibCongressNum = null char janAuthor = null char janTitle = null comment: file: "febResources" char febLibCongressNum = null char febAuthor = null char febTitle = null comment: end processing flag variable char bothAtEof = "N" comment: record comparison variable char previousLibCongressNum = null comment: files: "janResources" & "febResources" open files read janResources if eof then janLibCongressNum = "ZZZZZZZZZZ" endif read febResources if eof then febLibCongressNum = "ZZZZZZZZZZ" endif if janLibCongressNum == "ZZZZZZZZZZ" then if febLibCongressNum == "ZZZZZZZZZZ" then bothAtEof = "Y" endif endif return
C Syntax (Toggle Plain Text)
mainLoop() comment: if the value of "janLibCongressNum" is < "febLibCongressNum", the comment: assumption is that "janResources" is not at eof & the record must comment: be written; subsequent comparison of "janLibCongressNum" ensures comment: that duplicate resource info is not written to file. if janLibCongressNum < febLibCongressNum then if janLibCongressNum == previousLibCongressNum then while janLibCongressNum == previousLibeCongresNum then read janResources endwhile if eof then janLibCongressNum = "ZZZZZZZZZZ" endif else set previousLibCongress = janLibCongressNum write janLibCongressNum, janAuthor, janTitle read janResources if eof file then janLibCongressNum = "ZZZZZZZZZZ" endif endif else comment: if the value of "janLibCongressNum" is > "febLibCongressNum", the comment: assumption is that "febResources" is not at eof & the record must comment: be written; subsequent comparison of "febLibCongressNum" ensures comment: that duplicate resource info is not written to file. if febLibCongressNum < janLibCongressNum then if febLibCongressNum == previousLibCongressNum then while febLibCongressNum == previouLibCongressNum then read febResources endwhile if eof then febLibCongressNum = "ZZZZZZZZZZ" endif else set previousLibCongressNum = febLibCongressNum write febLibCongressNum, febAuthor, febTitle read febResources if eof then febLibCongressNum = "ZZZZZZZZZZ" endif endif else comment: if the value of "janLibCongressNum" equals "febLibCongressNum", comment: it must be determined if either record (or both), is a duplicate comment: record - the easiest way to do this is to determine if the equity comment: value has already been written, requiring one or the other comment: variable's value to be compared to the last record written & then comment: letting the next iteration of "mainLogic()" to process the other comment: equity value; for simplicity the "janLibCongressNum" variable was comment: chosen for the first equity camparison. if janLibCongressNum == febLibCongressNum then if janLibCongressNum == previousLibCongressNum then while previousLibCongresNum == janLibCongressNum then read janResources endwhile if eof then janLibCongressNum = "ZZZZZZZZZZ" endif else set previousLibCongressNum = janLibCongressNum write janLibCongressNum, janAuthor, janTitle read janResources if eof then janLibCongressNum = "ZZZZZZZZZZ" endif endif endif endif endif if janLibCongressNum == "ZZZZZZZZZZ" then if janLibCongressNum == "ZZZZZZZZZZ" then bothAtEof = "Y" endif endif return
finishUp() pseudocode
C Syntax (Toggle Plain Text)
finishUp() close files return
TIA
Last edited by aeinstein; Jul 6th, 2006 at 1:49 am.
"I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use." - Galileo Galilei
"Science without religion is lame. Religion without science is blind." - Albert Einstein
"Good judgment comes from experience, experience comes from bad judgment." - author unknown
"Anyone who has never made a mistake has never tried anything new." - Albert Einstein
(why "aeinstein"?)
Peace Be with You
"Science without religion is lame. Religion without science is blind." - Albert Einstein
"Good judgment comes from experience, experience comes from bad judgment." - author unknown
"Anyone who has never made a mistake has never tried anything new." - Albert Einstein
(why "aeinstein"?)
Peace Be with You
>but the follow-on problem required that any redundant records, regardless of file of origin, not be written to the merged file
The sudo code for this is:-
:lol:
The sudo code for this is:-
C Syntax (Toggle Plain Text)
if ( records = redundant) then don't write to file endif else write to file end
:lol:
*Voted best profile in the world*
![]() |
Similar Threads
- pls check flowchart for errors/inefficiencies (C)
- Pls can some one check my log asap?! (Viruses, Spyware and other Nasties)
- hjt log pls help cleanup (Viruses, Spyware and other Nasties)
- HJT pls check for nasties (Viruses, Spyware and other Nasties)
- Urgent Pls Help: My codes are in errors! (C++)
- Urgent: I need Help in c++.net! (ASP.NET)
Other Threads in the C Forum
- Previous Thread: why following output ???
- Next Thread: Spiral Order Of Matrix
Views: 1782 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays asterisks binarysearch calculate centimeter char command convert copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory dynamic executable fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix problem probleminc program programming radix recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming spoonfeeding stack standard string strings structures student systemcall testautomation turboc unix user variable voidmain() wab win32 windows.h






