Trusted by 2+ million users,
1000+ happy students everyday
Showing pages 1 to 3 of 7 pages
COMP20005 Assignment 1, 2017s1Last updated: April 28, 2017Oldest entries are at the bottom.Items 1-10 were in place when this page was first released on 5 April.Submission InstructionsThe submission process was illustrated starting at around the forty-three minutemark of the lecture on Friday 7 April. Review that lecture section if you are havingtrouble withsubmit.Information and Resources23.Programs that Crash on dimefox: Note that ondimefoxthe programs arebeing executed in non-interactive mode, and partial outputdoesnotautomatically get captured if the program crashes. This can make ithard to determine where it is in the program that the problem is occuring.Best bet is to put a commandfflush(stdout);after each Stage's output iscomplete, so that anything generated by that stage is guaranteed to becaptured in the output stream. You can add this after anyotherprintf()statements in the program too, if you want to be sure that youwant to capture every ounce of output generated. Then what you seewithverifyshould be the same as what you would have seen if you had runthe program interactively at the command-line. You may leavethefflush()statements in place when you submit, or include them as partof what is controlled byDEBUG, see #19.22.Upper Bound on Arrays: A couple of students have said that on theircomputers the 50,000 limit cannot be achieved, that their programs failswith a Segmentation Fault error if multiple arrays of that size are declared aslocal variables in themain(). You may decrease the limit to 20,000 if youare experiencing this problem.21.Assert? (A question from "an awestruck & brainwashed programmingstudent"). The sample solution to 2015 hasassert.hincluded. If you includethis, it gives you access to the functionassert()and enables you to writethings in your program like:22./* compute average */23.assert(denominator>0);24.avg = numerator/denominator;where you are sure that the denominator will be positive, and you think theprogram is correctly computing the things you want, but if something hasgone wrong (bizarre data, or weird unexpected input combinations, or
whatever) you want to get a "soft crash" rather than a "hard crash". Whathappens is that the expression in the assert gets tested at runtime, and if it isnot true, the program will halt at this point, and print the line number andfile nname, and the assertion that failed. Try it if you like!20.Stage 4 Output: Yes, one of the input files you have been given(data00031.txt) doesn't comply with the specification, because it doesn't fitthe description of "you may assume that each year that is represented in theinput will have data for all twelve months (so that the scores are always outof 24)". This question came up at the beginning of the lecture on Monday 24April; please listen to that before asking again about it. My programgenerates 0/2 for that data file, and 0/24 will also be regarded as beingcorrect for this data file. Ok?19.DEBUG, huh? Student question, "Sir-oh-illustrious-one, I noticed in yourprogram yesterday that you had a#define DEBUG 0, what was that about?"Yes, good question. At the top of the program I have20.#define DEBUG 0and then right through the program I can do things likeif (DEBUG) {printf("line %3d, x = %d\n", __LINE__, x);}which doesn't do anything whenDEBUGis zero, but prints out the programline number and the value ofxwhenDEBUGis 1. This lets you put helpfuldebuggingprintf()s right through your program, and then switch them all"off" by changingDEBUGto 0. Then they can stay there in the code, inactive,in case they are needed again later. The constant__LINE__(two underscorecharacters on each side) gets expanded to the current line number by thecompiler when it is processing your program. (Just make sure thatDEBUGiszero when you submit your final version, of course.)18.File Operations: Student question, "Can we usefopen()in our programs?No, on no account should you be usingfopen()in your programs. The datathat your program will execute on in the test harness will be supplied viaredirection ofstdin. If you try and open a named file usingfopen()yourprogram willfail.17.Stage 4 Output: I have had this question several times now, "When we'regiven between 6 and 9 years of data, how should it be printed out in Stage4? I agree that the spec doesn't cover this case, and so anythingreasonable/sensible will be accepted. But for concreteness, if you want to betold what is reasonable/sensible, feel free to implement this rule: "at most 5lines at the beginning, followed by a -- if any lines are omitted, followed by
at most five lines from the end, with no lines duplicated". Both of these nextexamples would fit that rule:18.Stage 419.-------20.2009: score is nn/2421.2010: score is nn/2422.2011: score is nn/2423.2012: score is nn/2424.2013: score is nn/2425.2014: score is nn/2426.2015: score is nn/2427.2016: score is nn/2428.29.Stage 430.-------31.2006: score is nn/2432.2007: score is nn/2433.2008: score is nn/2434.2009: score is nn/2435.2010: score is nn/2436.--37.2012: score is nn/2438.2013: score is nn/2439.2014: score is nn/2440.2015: score is nn/2441.2016: score is nn/24wherennis the score you have to calculate.16.Debugging: Yes, I do sometimes take a look at programs if you are stuck(debugging is also fun!), and can usually identify issues that might be givingyou your problems. But please don't just mail me a screenshot, or paste alittle bit of program fragment into an email -- I'll want to see the wholeprogram. Sosubmitit ondimefoxso that I can see all of it (and whathappens when it executes)beforesending me a nice email that says "DearSir, I'm really truly enjoying your lectures, and indeed I am beginning to seejust how much fun programming could be (and I would very definitely tomake it even more fun in the future), but I have a slight problem right nowthat is detracting from the immense fun experience. Would you mind, oh-inspirational-one, taking a look at my current submission and see if you canexplain why" and then summarize the symptoms of the problem that youare having. I wouldn't go so far as to say that I answer such emails in orderof decreasing obsequiousness, but the ones that are truly sucky do certainlymake me smile...15.Question from a student: On the first page, you state that it is 45 years forthe data from 1971-2016 inclusive. Wouldn't it actually be 46 yearsincluding both 1971 and 2016?: Yes, you are right. That's a mistake, 1971-2016 is indeed 46 years.
Desklib Logo
You are reading a preview
Upload your documents to download or

Become a Desklib member to get access