” CSSE2310程序语言 辅导、 写作C/C++编程The University of QueenslandSchool of Information Technology and Electrical EngineeringCSSE2310/CSSE7231 Semester 1, 2021Assignment 1 (v1.1 – 8 March 2021)Marks: 75 (for CSSE2310), 85 (for CSSE7231)Weighting: 10%Due: 3:59pm 19 March, 2021Specification changes since version 1.0 are shown in red and are summarised at the end of the document.IntroductionThe goal of this assignment is to Give you practice at C programming. You will be building on this ability inthe remainder of the course (and subsequent programming assignments will be more difficult than this one).You are to create a program (called search) which searches a dictionary of words to find words that match acertain pattern of letters and blanks. For example, you might use such a program to find all 5 letter words thatbegin with a and end with t. The assignment will also test your ability to code to a particular programmingstyle guide.Student conductThis is an individual assignment. You should feel free to discuss general aspects of C programming andthe assignment specification with fellow students, including on the discussion forum. In general, questions likeHow should the program behave if hthis happensi? would be safe, if they are seeking clarification on thespecification.You must not actively help (or seek help from) other students or other people with the actual design andcoding of your assignment solution. It is cheating to look at another students assignment code andit is cheating to allow your code to be seen or shared in printed or electronic form by others.All submitted code will be subject to automated checks for plagiarism and collusion. If we detect plagiarismor collusion, formal misconduct Proceedings will be initiated against you, and those you cheated with. Thatsright, if you share your code with a friend, even inadvertently, then both of you are in trouble. Do not postyour code to a public place such as the course discussion forum or a public code repository, and do not allowothers to access your computer – you must keep your code secure.Uploading or otherwise providing the assignment specification to a third party including online tutorial andcontract cheating websites is considered misconduct. The university is aware of these sites and they cooperatewith us in misconduct investigations.You may use code provided to you by the CSSE2310/CSSE7231 teaching staff in this current semesterand you may use code examples that are found in man pages on moss. If you do so, you must add a comment inyour code (adjacent to that code) that references the source of the code. If you use code from other sources thenthis is either misconduct (if you dont reference the code) or code without academic merit (if you do referencethe code). Code without academic merit will be removed from your assignment prior to marking (which maycause compilation to fail) but this will not be considered misconduct.The course coordinator reserves the right to conduct interviews with students about theirsubmissions, for the purposes of establishing genuine authorship. If you write your own code,you have nothing to fear from this process.In short – Dont risk it! If youre having trouble, seek help early from a member of the teaching staff.Dont be tempted to copy another students code or to use an online cheating service. You should read andunderstand the statements on student misconduct in the course profile and on the school web-site: httpss://www.itee.uq.edu.au/itee-student-misconduct-including-plagiarismSpecificationCommand Line ArgumentsYour program (search) is to accept Command line arguments as follows:1./search [-exact|-prefix|-anywhere] [-sort] pattern [filename]In other words, your program should accept between one and four command arguments – zero, one or two optionarguments followed by a pattern, then optionally followed by a dictionary filename. The option argument thatspecifies the type of search is ONE of -exact, -prefix or -anywhere. If this argument is not given, the defaultsearch type is -exact. Search types are explained below. If the -sort argument is present, then the outputwill be sorted alphabetically (also explained below). The -sort option may come before the search type optionif both are present. The only argument which must always be present is the pattern itself. The pattern consistsonly of question mark characters and/or letters (upper or lower case) and may be empty. A question markindicates a match with any letter. Some example patterns are:abca?dA???c?e?b?D???The last argument (if present) is the path name of the dictionary file, i.e. the name of a file containingwords one per line. Each line (including the last) is assumed to be terminated by a newline character (\n)only. You may assume there are no blank lines and that no words are longer than 40 characters. The filenamecan be relative to the current directory or Absolute (i.e. begins with a /). Some examples are:/usr/share/dict/words../dictnamemydictionary (refers to a file with this name in the current directory)If the filename is not specified, the default should be used (/usr/share/dict/words).Program OperationThe program is to operate as follows If the program receives an invalid command line, e.g. (but not limited to) an invalid number of commandline arguments, or an option argument begins with and it is not one of -exact, -prefix, -anywhere or-sort, or if more than one search type argument is present, then your program should print the message:Usage: search [-exact|-prefix|-anywhere] [-sort] pattern [filename]to standard error, and exit with a non-zero exit status. If the given dictionary filename does not exist or can not be opened for reading, your program shouldprint the message:search: file filename can not be openedto standard error, and exit with a non-zero exit status. (The italicised filename is replaced by the actualfilename i.e. the argument given on the command line. The double quotes must be present.) If the given pattern contains characters other than question marks (?) and letters (either case), then yourprogram should print the message:search: pattern should only contain question marks and lettersto standard error, and exit with a non-zero exit status. Your program should then print out all lines in the given file that match the given pattern (if any). Linesare printed to standard output. The details of the pattern matching are described below. When allmatches have been printed, your program should exit. If at least one match was printed, your programshould exit with an exit status of zero. If no matches were reported, your program should exit with anon-zero exit status. Advanced Functionality: If the -sort argument is present, then the output lines must be sortedalphabetically – i.e. in the same order as a standard dictionary, with the case of each letter being ignoredfor sorting purposes (but the case of the words in the dictionary must be preserved when output). If twomatching words are identical for sorting purposes, e.g. Miss and miss, then they may be output in eitherorder.Without the -sort argument, then the output lines must be in the same order as they were in thedictionary file. If you do not implement this advanced functionality, then your program should just ignorethe -sort argument and output lines in The same order as they were in the dictionary file. (i.e. do notthrow an error if -sort is specified but not implemented by your program).2Pattern Matching Types of SearchAs indicated above, there are three types of search (exact, prefix and anywhere). An exact match (the defaulttype) means that the pattern should match a word exactly – matched words will be the same length as thepattern and each character in the pattern matches the corresponding character in the word (upper or lower case).A question mark in the pattern matches any letter in the word (but not numbers or punctuation characters).For example, consider a dictionary file containing the following lines:3rdArcticardencyardentarduousareareaarenaarentListing 1: Sample dictionary fileWith exact matching, the pattern ?r? will match are only (but not 3rd). The pattern are willmatch Arctic and ardent but not arent.(Words that contain nonalphabetic characters such as numbers, hyphens or apostrophes are never reportedas matches for any of the search types.)With prefix matching, the pattern matches the beginning part of the word i.e. any number of letters(including zero) may follow the matching characters. For a file containing the lines given above, the prefixpattern are will match are, area and arena. The prefix pattern ????? will match all words which arefive or more letters long (and contain only letters).With anywhere matching, the pattern matches any part of the word, i.e. any number of letters (includingzero) may precede the matching Characters and any number of letters (including zero) may follow the matchingcharacters. For a file containing the lines given above, the anywhere pattern en will match ardency, ardentand arena. The anywhere pattern re? will match area and arena. The anywhere pattern T will matchArctic and ardent.An empty pattern will never be an exact match for any words, and will match every valid word for prefixand anywhere matching.Other functionalityYour program must print nothing to standard output other than matching words. Your program must printnothing to standard error other than the exact messages given above. (Your program will never print a messageto both standard output and standard error during the same run.)StyleYou must follow version 2.0.4 of the CSSE2310/CSSE7231 C programming style guide available on the courseBlackBoard site.Hints1. You may wish to consider the use of the standard library functions isalpha(), islower(), isupper(),toupper() and/or tolower(). Note that these functions operate on integers (ASCII values) so you willneed to cast characters to integers and vice versa as appropriate to avoid compiler warnings. For example,given that variable c is of type char, the following code will convert the character stored in c to uppercase (without compiler warnings):c = (char)toupper((int)c);2. Note that implementation of the advanced functionality (sorting) will require the use of dynamicallyallocated memory (i.e. with malloc() etc.) to store the list of words for sorting. Use of dynamicallyallocated memory is not required if you do not implement the advanced functionality (though you mayuse it if you wish).33. Some functions which may be useful Include strcmp(), strlen(), exit(), fopen(), fgets(), fprintf()and qsort().Forbidden FunctionsYou must not use any of the following C functions/statements. If you do so, you will get zero (0) marks for theassignment. goto() longjmp() and equivalent functions system() execl() or any other members of the exec family of functions POSIX regex functionsSubmissionYour submission must include all source and any other required files (in particular you must submit a Makefile).Do not submit compiled files (eg .o, compiled programs) or dictionary files.Your program must build on moss.labs.eait.uq.edu.au with:makeYour program must be compiled with gcc with at least the following switches:-pedantic -Wall –std=gnu99You are not permitted to disable warnings or use pragmas to hide them.If any errors result from the make command (i.e. the search executable can not be created) then you willreceive 0 marks for functionality (see below). Any code without academic merit will be removed from yourprogram before compilation is attempted (and if compilation fails, you will receive 0 marks for functionality).Your program must not invoke other programs or use non-standard headers/libraries.Your assignment submission must be committed to your subversion repository under httpss://source.eait.uq.edu.au/svn/csse2310-sXXXXXXX/trunk/ass1where sXXXXXXX is your moss/UQ login ID. Only files at this top level will be marked so do not put sourcefiles in subdirectories. You may create subdirectories for other purposes (e.g. your own test files) but thesewill not be considered in marking – they will not be checked out of your repository.The initial structure of the repository will be created for you. Your latest submission will be marked andyour submission time will be considered to be the commit time of your latest submission. If you commit afterthe assignment deadline then we will mark that latest version and a late penalty will apply, evenif you had made a submission (commit) before the deadline.You must ensure that all files needed to compile and use your assignment (including a Makefile) are committedand within the trunk/ass1 directory in your repository (and not within a subdirectory) and not justsitting in your working directory. Do not commit compiled files or binaries. You are strongly encouraged tocheck out a clean copy for testing purposes.The late submission policy in the CSSE2310/CSSE7231 course profile applies. Be familiar with it.MarksMarks will be awarded for functionality and style and documentation.Functionality (60 marks)Provided your code compiles (see above), you will earn functionality marks based on the number of featuresyour program correctly implements, as outlined below. Partial marks will be awarded for partially meeting thefunctionality requirements. Not all features are of equal difficulty. If your program does not allow a featureto be tested then you will receive 0 Marks for that feature, even if you claim to have implemented it.4For example, if your program can never open a file, we can not determine if your program can match patternscorrectly. If your program takes longer than 10 seconds to run any test, then it will be terminated and you willearn no marks for the functionality associated with that test. The markers will make no alterations to your code(other than to remove code without academic merit).Marks will be assigned in the following categories.1. Program correctly handles invalid command lines (6 marks)2. Program correctly handles dictionary files that are unable to be read (3 marks)3. Program correctly handles invalid patterns (3 marks)4. Program correctly performs exact pattern matching (without sorting) (12 marks)5. Program correctly performs prefix pattern matching (without sorting) (12 marks)6. Program correctly performs anywhere pattern matching (without sorting) (14 marks)7. Advanced Functionality: Program correctly matches patterns (of all types) with sorting (10 marks)Style (10 marks)Style marks will be calculated as follows: Let W be the number of distinct compilation warnings recorded when your code is built (using the correctcompiler arguments) A be the number of style violations detected by style.sh (automatic style violations) H be the number of additional style violations detected by human markers. Violations will not be countedtwiceYour style mark S will beS = 10 (W + A + H)If W + A + H 10 then S will be zero (0) – no negative marks will be awarded. H will not be calculated(i.e. there will be no human style marking) if W + A 10The number of style guide violations refers to the number of violations of version 2.0.4 of the CSSE2310/CSSE7231C Programming Style Guide.A maximum of 5 violations will be penalised for each broad guideline area. The broad guideline areas areNaming, Comments, Braces, Whitespace, Indentation, Line Length and Overall. For naming violations, thepenalty will be one violation per offending name (not per use of the name).You should pay particular attention to commenting so that others can understand your code. The markersdecision with respect to commenting violations is final – it is the marker who has to understand your code. Tosatisfy layout related guidelines, you May wish to consider the indent(1) tool. Your style mark can never bemore than your functionality mark – this prevents the submission of well styled programs which dont meet atleast a minimum level of required functionality.You are encouraged to use the style.sh tool installed on moss to style check your code before submission,however the marker has ultimate discretion the tool is only a guide.SVN commit history assessment (5 marks)Markers will review your SVN commit history for your assignment from the time of handout up to yoursubmission time.This element will be graded according to the following principles: Appropriate use and frequency of commits (e.g. a single monolithic commit of your entire assignment willyield a score of zero for this section) Appropriate use of log messages to capture the changes represented by each commitAgain, dont overthink this. We understand that you are just getting to know Subversion, and you wontbe penalised for a few test commit type messages. However, the markers must get a sense from your commitlogs that you are practising and developing sound software engineering practices by documenting your changesas you go. In general, tiny changes deserve small comments – larger changes deserve more detailed commentary.5Documentation (10 marks) – for CSSE7231 students onlyPlease refer to the grading critera available on BlackBoard under Assessment for a detailedbreakdown of how these submissions will be marked.CSSE7231 students must submit a PDF document containing a written overview of the architecture anddesign of your program.This document should describe, at a general level, the functional decomposition of the program, the key designdecisions you made and why you made them. Submitted via Blackboard/TurnItIn prior to the due date/time Maximum 2 A4 pages in 12 point font Diagrams are permitted up to 25% of the page area. The diagram must be discussed in the text, it is notok to just include a figure without explanatory discussion.Dont overthink this! The purpose is to Demonstrate that you can communicate important design decisions,and write in a meaningful way about your code. To be clear, this document is not a restatement of the programspecification – it is a discussion of your design and your code.If your documentation obviously does not match your code, you will get zero for this component,and will be asked to explain why.Total markLet F be the functionality mark for your assignment. S be the style mark for your assignment. V be the SVN commit history mark. D be the documentation mark for your assignment (for CSSE7231 students).Your total mark for the assignment will be:M = F + min{F, S} + min{F, V } + min{F, D}out of 75 (for CSSE2310 students) or 85 (for CSSE7231 students).In other words, you cant get more marks for style or SVN history or documentation than you do for functionality.Pretty code that doesnt work will not be rewarded!Late PenaltiesLate penalties will apply as outlined in the course profile.Specification UpdatesAny errors or omissions discovered in the assignment specification will be added here, and new versions releasedwith adequate time for students to respond prior to due date. Potential specification errors or omissions can bediscussed on the discussion forum or Emailed to csse2310@helpdesk.eait.uq.edu.au.Version 1.1 – 8 March 20211. Clarified that if the dictionary file does not exist then it is the complete filename argument (which mayinclude a path) which is printed as part of the error message.2. Updated the list of forbidden functions to make it clear that POSIX regex functions can not be used (aswas stated already on the Assessment page in Blackboard).3. Updated the description of invalid command lines to make it clear that the list given is an example ofinvalid command lines but not a complete list and to make it clear that the filename argument mightbegin with .64. Specified that any C source files and the Makefile necessary to build your search program must be atthe top level in your assignment one repository (i.e. in trunk/ass1) and not in a subdirectory. Anysubdirectories in your assignment one submission will be ignored for marking purposes (but you may usethem for your own purposes, e.g. test files).5. Specified that the limit on any test run is 10 seconds. You will earn no marks for the functionalityassociated with that particular test if your program takes longer than 10 seconds to complete the test.6. Clarified that the pattern command line Argument may be empty and that an empty pattern will neverbe an exact match for any words, and will match every valid word for prefix and anywhere matching.如有需要,请加QQ:99515681 或WX:codehelp
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。