辅导COMP281编程、 写作C++语言程序

” 辅导COMP281编程、 写作C++语言程序COMP281 2020-2021 Assignment 2? In the following, you will find the problems that constitute Assignment 2. They will be also availableon the online judging (OJ) system available at httpss://student.csc.liv.ac.uk/JudgeOnline? You need to write a C program (not C++ or C#) that solves each problem it must read the input, asspecified in the problem description then print the solution to the given problem for that input.o Note that code is correct only if it Correctly implements a solution to the problem statedin the assignment, not if online judge accepts it.o That is, even if OJ accepts your code, it could be wrong. Read the problems carefully.? Input is read from the standard input, in The same way that you read input from the keyboard as shownin lectures (e.g., using scanf). Output is Also printed to the standard output, as you have seen (e.g.,using printf).? When you are satisfied that your C programs work correctly, you must submit them through thedepartmental submission system.o Even if the program is not correct, still submit whatever you have! You can still earn points ifcertain parts of the code are done right.? You must also include a brief report describing your solutions to the problems. This should bemaximum two sides of A4 paper and should give a description of how each of your solutions works.This should include describing the algorithm Used to reach the solution, describing your use of any Clanguage features (that were not discussed in lectures) and identifying any resources that you haveused to help you solve the problems.? This assignment is worth 50% of the total mark for COMP281.o Both problems are weighted equally.o For each problem, you can earn a total of 50 points 25 points for Functionality and Correctness awarded for programs that correctlysolve the problem for all test Cases. 20 points for Programming style, use of comments, indentation and identifiersawarded depending on the style, comments and efficiency of the solution 5 points for the quality and depth of the accompanying reporto The final grade results from Normalising the earned points to a scale of 100.o See separate comp281-detailed-marking-guidelines.pdf for more details.Submission Instructions? Create a folder, and name it using your Student ID and User ID, e.g. 201234567_sgpj6? In the folder, there should be 3 files:o 1 report file, in PDF format. Name it with your Student ID and User ID, e.g.201234567_sgpj6.pdfo 2 source code files. Name each using the Problem Number, e.g. 1006.c In your source Code, include your Student Info and Problem Info, e.g.:/** Student ID: 201234567* Student Name: Phil Jimmieson* Email: phil.jimmieson@student.liverpool.ac.uk** User: sgpj6** Problem ID: 1006* RunID: 22456* Result: Accepted*/ The OJ provides a RunID, which is different from the Problem ID. The Result is one of the following: Accepted, Wrong Answer, Presentation Error, TimeLimit Exceeded, Memory Limit Exceeded, Output Limit Exceeded, Runtime Error,Compile Error.? Compress the folder into a single zip file, and name it as, e.g. 201234567_sgpj6.zipo Use the standard (pkzip) zip file format: httpss://en.wikipedia.org/wiki/Zip_%28file_format%29which is supported by winzip, winrar, etc. on Windows/Mac OS X, and zip on Linuxo Test your zip file before submitting.? Submit this zip file using the departmental submission system at https://www.csc.liv.ac.uk/cgi-bin/submit.plOnly the file submitted through this link will be marked.? The deadline for this assignment submission is 18-Mar-2021 at 17:00? Penalties for late submission Apply in accordance with departmental policy as set out in the studenthandbook, which can be found at: https://intranet.csc.liv.ac.uk/student/ug-handbook.pdf1. Problem 1086Title: Run Length Encoding of ASCII ArtDescriptionIn the very early days of computing, images were produced using ASCII characters. Such ASCII Art was very popularand, since storage was limited, simple techniques were developed to compress such images. One such simpletechnique of lossless compression was Run Length Encoding. This scans an input image for runs (sequences) of 2 ormore identical values, and replaces them with two such characters followed by an INT string representing a count ofthe number of characters, and terminated by a * e.g.A line from a piece of ASCII Art image as follows:,,,,,,]F 8,which is composed of 6 commas, a closed square bracket, a capital F, 48 spaces an eight and a comma, would berepresented as:,,6*]F 48*8,Write a program to accept as input either the letter C or the letter E followed by a carriage return. Each subsequentline of input data until EOF contains image data.If the initial input was C this represents compress, and the lines of input text represent an ASCII Art image.Process this input to compress it using the Rules specified above, and output the compressed version.If the initial input was E this represents expand, and the lines of input text represent a compressed ASCII Artimage. Process this input and expand it using the rules referred to above. Print out this uncompressed ASCII Artimage.You can test your program by compressing an ASCII Art image, saving the output to a file, editing the file to add E asthe first line, then feeding this back into your program to effectively reproduce the original ASCII Art image. If yourprogram is working correctly then the original image and your compressed then decompressed version should beidentical.InputEither an ASCII art file with a C on the first line (this will be compressed using RLE)orA compressed ASCII art file with an E on the first line (this will be expanded).OutputAfter compressing an input file, all runs of two or more of any character should be replaced by two of the character, aninteger count and a star.After expanding an input file, all previously compressed sequences should be replaced by the original character runs.Sample InputHintYoull need to use a mono-spaced font to view the art correctly (proportionally spaced fonts distort the layouts).Use scanf to retrieve individual characters from the standard input and process them as you read them in (no need tostore them in arrays).You can convert a digit char to an int value (i.e. 1 = 1, 2 = 2 etc) using:intValue = ((int) inputChar) – 48;2. Problem 1088Title: Matching Word CountDescriptionWrite a program that accepts as input an ASCII string (a word) of max length 20 characters. Thisword is the search term that your program will use. It should then read in the remaining input text(e.g. a poem), which features a series of lines (each of no more than 100 characters in length)comprising zero or more words (each of at most 20 characters) in ASCII (which may include somepunctuation characters that must be removed). Your C program should process that text into a seriesof individual words (i.e. strings separated from one another by space, comma or full-stop), filter anynon-alphabetic characters from the words, and compare them with the search word. A count of thenumber of times the search word is found in the text should be maintained, and printed out at the endof the processing.The output should be the search word, along with a count of how many times that word was found inthe text.InputA word of at most 20 characters on a line on its own, followed by a number of lines of text (each of 100characters at most, featuring 0 or more words of at most 20 characters each)OutputThe search word, followed by a = string and then an integer count of how many times that word wasfound in the text.Sample InputjabberWockThe JabberwockTwas brillig, and the slithy tovesDid gyre and gimble in the wabe:All mimsy were the borogoves,And the mome raths outgrabe.Beware the Jabberwock, my son!The jaws that bite, the claws that catch!Beware the Jubjub bird, and shunThe frumious Bandersnatch!He took his vorpal sword in hand;Long time the manxome foe he soughtSo rested he by the Tumtum treeAnd stood awhile in thought.And, as in uffish thought he stood,The Jabberwock, with eyes of flame,Came whiffling through the tulgey wood,And burbled as it came!One, two! One, two! And through and throughThe vorpal blade went snicker-snack!He left it dead, and with its headHe went galumphing back.And hast thou slain the Jabberwock?Come to my arms, my beamish boy!O frabjous day! Callooh! Callay!He chortled in his joy.Twas brillig, and the slithy tovesDid gyre and gimble in the wabe:All mimsy were the borogoves,And the mome raths outgrabe.Sample OutputjabberWock=4HINTSIt is easier to compare two strings if they are converted to uppercase (or to lowercase) first.Your program needs to process text until an EOF is encountered (indicating the end of the text). When testingyour program yourself (not via online judge), it is difficult to generate an EOF on some platforms. It is simplerto prepare your test input data in a text file, and then pipe that data into your program using e.g. if yourprogram has been compiled into the a.out file then:./a.out sourcetext.txtwill send the contents of sourcetext.txt into your program, and when all the contents of that file have beenprocessed, your program will receive an EOF on the input stream.You might find the string library function strtok() useful to solve this problem.如有需要,请加QQ:99515681 或WX:codehelp

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导