http:^^www.cs.wisc.edu^~mbirk^cs302^assignments^prog4.html

来自「This data set contains WWW-pages collect」· HTML 代码 · 共 183 行

HTML
183
字号
Date: Mon, 11 Nov 1996 17:00:42 GMTServer: NCSA/1.5Content-type: text/htmlLast-modified: Tue, 15 Oct 1996 13:48:57 GMTContent-length: 5080<html><head><title> Program 4 </title><center> <h2> Program 4 </h2> </center></head><body><ul><li> CS302 Section 12<li> TA: Michael Birk<li> <strong> Assigned: </strong> Tue 10/15/96<li> <strong> Due: </strong> Tue 10/22/96</ul><p> For this assignment, you will write a program that is capableof drawing a variety of shapes.  The shapes supported by your programinclude a square, a rectable, an isoscoles triangle, and a diamond.Each shape can be printed "solid" or "hollow" using any desiredcharacter.<p> Your program should be menu-driven, so that the user is repeatedlypresented with a menu of their options - the various shapes to print,and the current settings of the options (solid or hollow and printingcharacter).<p> You should also check for invalid input.  If the user enters invalid input, you should display an error message and promt the userto re-enter the information.<p> Note: In general, code "duplication" is bad - you don't want tohave identical or very similar code repeated throughout your programif it isn't necessary.  Instead, you should try writing one functionwhich does the job.  Often it is necessary to generalize that functionby adding more parameters.  For this program, you <strong>don't</strong>need separate hollow and solid printing functions for each of thedifferent shapes!  In addition, it is possible to put thevalid-input-checking code in one function and avoid duplicating it allover the place.<h3> What to Hand In </h3><p> You should hand in your source code, and the program's output showing<b>all</b> four shapes being printed in <b>both</b> solid and hollow mode.The overall format of the output should be very similar to the sample outputbelow.<h3> Notes and Hints </h3><ul>  <li> Your menu should display the current <b>printing character</b>       and whether you are in <b>hollow or solid mode</b>.  <li> You <b>must</b> document all of the functions in your program with       comments; this documentation should explain what the function does,       what the meanings of the inputs and outputs are, and what side       effects the function has.  <li> Do <b>not</b> use any global variables in your program; all variables       should be local to a function.  Use function parameters to pass       information into a function.  <li> For each shape, choose minimum and maximum values for the number       of rows, width, etc.  Use a loop to check that the value given by       the user is in the correct range.  <li> The square is just a special case of the rectangle with the same       width and height.</ul><h3> Sample Output </h3><pre>Welcome to John Q. Doe's shape-printing program!  Here are youroptions:D - Print a diamond shape   C - Change character (currently *)Q - Print a square          H - Switch between hollow/solidR - Print a rectangle           (currently solid)T - Print a triangle        X - Exit programWhat is your selection? QHow many rows? 3   ***   ***   ***D - Print a diamond shape   C - Change character (currently *)Q - Print a square          H - Switch between hollow/solidR - Print a rectangle           (currently solid)T - Print a triangle        X - Exit programWhat is your selection? rHow many rows? 2How many columns? 12   ************   ************D - Print a diamond shape   C - Change character (currently *)Q - Print a square          H - Switch between hollow/solidR - Print a rectangle           (currently solid)T - Print a triangle        X - Exit programWhat is your selection? CWhat character to print with? &What is your selection? DWhat size diamond? 3     &    &&&   &&&&&    &&&     &D - Print a diamond shape   C - Change character (currently &)Q - Print a square          H - Switch between hollow/solidR - Print a rectangle           (currently solid)T - Print a triangle        X - Exit programWhat is your selection? hNow in hollow mode.D - Print a diamond shape   C - Change character (currently &)Q - Print a square          H - Switch between hollow/solidR - Print a rectangle           (currently hollow)T - Print a triangle        X - Exit programWhat is your selection? THow many rows? -1-1 is not a valid size.  Please try again.How many rows? 5       &      & &     &   &    &     &   &&&&&&&&&D - Print a diamond shape   C - Change character (currently &)Q - Print a square          H - Switch between hollow/solidR - Print a rectangle           (currently solid)T - Print a triangle        X - Exit programWhat is your selection? ZZ is not a valid menu choice!What is your selection? cWhat character to print with? %What is your selection? RHow many rows? 4How many columns? 8   %%%%%%%%   %      %   %      %   %%%%%%%%D - Print a diamond shape   C - Change character (currently %)Q - Print a square          H - Switch between hollow/solidR - Print a rectangle           (currently solid)T - Print a triangle        X - Exit programWhat is your selection? xGoodbye!</pre></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?