{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eYou work for a company which uses lots of personal computers. Your boss, Dr \n Penny Pincher, has wanted to link the computers together for some time but has \n been unwilling to spend any money on the Ethernet boards you have recommended. \n You, unwittingly, have pointed out that each of the PCs has come from the vendor \n with an asynchronous serial port at no extra cost. Dr Pincher, of course, recognizes \n her opportunity and assigns you the task of writing the software necessary to \n allow communication between PCs.\u003c/p\u003e\n\u003cp\u003e You\u0027ve read a bit about communications and know that every transmission is \n subject to error and that the typical solution to this problem is to append \n some error checking information to the end of each message. This information \n allows the receiving program to detect when a transmission error has occurred \n (in most cases). So, off you go to the library, borrow the biggest book on communications \n you can find and spend your weekend (unpaid overtime) reading about error checking.\u003c/p\u003e\n\u003cp\u003e Finally you decide that CRC (cyclic redundancy check) is the best error checking \n for your situation and write a note to Dr Pincher detailing the proposed error \n checking mechanism noted below.\u003c/p\u003e\n\u003cp\u003eThe message to be transmitted is viewed as a long positive binary number. The \n first byte of the message is treated as the most significant byte of the binary \n number. The second byte is the next most significant, etc. This binary number \n will be called \"m\" (for message). Instead of transmitting \"m\" \n you will transmit a message, \"m2\", consisting of \"m\" followed \n by a two-byte CRC value. \u003c/p\u003e\n\u003cp\u003eThe CRC value is chosen so that \"m2\" when divided by a certain 16-bit \n value \"g\" leaves a remainder of 0. This makes it easy for the receiving \n program to determine whether the message has been corrupted by transmission \n errors. It simply divides any message received by \"g\". If the remainder \n of the division is zero, it is assumed that no error has occurred.\u003c/p\u003e\n\u003cp\u003eYou notice that most of the suggested values of \"g\" in the book are \n odd, but don\u0027t see any other similarities, so you select the value 34943 for \n \"g\" (the generator value).\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eInput\u003c/b\u003e\u003cbr\u003e\n \u003cbr\u003e\n You are to devise an algorithm for calculating the CRC value corresponding to \n any message that might be sent. To test this algorithm you will write a program \n which reads lines (each line being all characters up to, but not including the \n end of line character) as input, and for each line calculates the CRC value \n for the message contained in the line, and writes the numeric value of the CRC \n bytes (in hexadecimal notation) on an output line. Each input line will contain \n no more than 1024 ASCII characters. The input is terminated by a line that contains \n a # in column 1.\u003cbr\u003e\n \u003cbr\u003e\n \u003cbr\u003e\n\u003c/p\u003e\n\u003cp\u003e\u003cb\u003eOutput\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eCRC in hex format, one on each line. Note that each CRC printed should be in \n the range 0 to 34942 (decimal). \u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eSample Input\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003ethis is a test\u003c/p\u003e\n\u003cp\u003eA\u003cbr\u003e\n #\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eSample Output\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003e77 FD \u003cbr\u003e\n 00 00\u003cbr\u003e\n 0C 86\u003cbr\u003e\n\u003c/p\u003e"}}]}