C代写:CS158 Team Trivia Competition

Introduction

代写一个C语言的小作业,解决几个小问题。

Problem

During a team trivia competition each team submits their answer and correct answers are recorded by the team number in the order they are received. Determine which team answered the most questions correctly. When more than one team has the name number of correct answers the winning team is the one that submitted their final answer first.

  • It is possible for 100 entries to be given as input. All team numbers are positive integers. If there are fewer than 100 teams to record then the data will terminate with the input of a - 1 value.

Example Execution #1:

Enter final results: 7 5 7 3 2 2 7 1 1 7 -1
The winning team is # 7 with 4 total correct answers.

Example Execution #2:

Enter final results: 1 2 3 1 2 3 1 2 3 -1
The winning team is # 1 with 3 total correct answers.
  • Team #1 was the first to submit the correct answer to their third problem.

Example Execution #3:

Enter final results: 90 33 11 22 90 33 11 22 90 33 11 22 90 33 11 11 22 90 90 33 11 33 22 33 22 11 11 22 90 33 11 22 90 33 11 22 90 33 11 22 90 33 11 22 90 33 11 22 90 33 11 22 90 33 11 22 90 33 11 22 90 33 11 22 90 33 11 22 25...
The winning team is # 11 with 25 total correct answers.
  • The -1 is not needed when the limit of 100 answers have been submitted. Be sure to try your program with 99 and a final -1 value, this is a common mistake in a problem such as this one.

Example Execution #4:

Enter final results: 123456 12345 1234 123 12 1 21 321 4321 54321 654321 -1
The winning team is # 123456 with 1 total correct answers.
  • All teams submitted only a single answer.

Example Execution #5:

Enter final results: 1 2 3 3 2 1 1 2 3 3 2 1 -1
The winning team is # 3 with 4 total correct answers.

Additional Requirements

  1. Add the homework assignment header file to the top of your program. A description of your program will need to be included in the assignment header. This particular header can be added to your file by entering hhw while in command mode in vi .
  2. Each example execution represents a single test of your program. The five examples provided imply that the program was run five different times.
    • Your program is expected to accept input and produce output in the same manner demonstrated above.
    • Every execution of your program will include at least one team submission prior to the -1 value.
    • All data entered as input and produced as output will fit within int type of integer value.
    • Do not add any “bonus” features not demonstrated in the example executions provided.
  3. Course standards prohibit the use of programming concepts not yet introduced in lecture. For this assignment you can consider all material in the first eight chapters of the book, notes, and lectures to be acceptable for use.
    • The use of variable-length or dynamically-allocated arrays will result in no credit being awarded for your effort.
  4. For this assignment you will be required to implement the user-defined functions (from chapter 4). Failing to follow course standards as they relate to good user-defined function use will result in a zero for this assignment.
  5. A program MUST compile to be considered for partial credit. The submission script will reject the submission of any file that does not successfully compile on the guru server. The name of the source code file you attempt to submit must be hw07.c, no variation is permitted.

Course Programming and Documentation Standards Reminders

  • Use the course function header (head_fx vi shortcut hfx while in command mode) for every user-defined function in your program.
    • List and comment all parameters to a function, one per line, in the course function header.
    • All function declarations will appear in the global declaration section of your program.
    • The user-defined function definitions will appear in your program after the main function.
  • Indent all code within relevant selection and repetition constructs two additional spaces.
  • Make use of { and } with all relevant selection and repetition constructs.
  • Place a single space between all operators and operands.
  • Comment all variables to the right of each declaration. Declare only one variable per line.
  • Notice that several programs (see program 2-9 on pages 74-75) in the programming text use a single line comment to indicate the start of the local declaration and executable statement sections of the main function.
    • At no point during the semester should these two sections ever overlap. You might consider adopting this habit of commenting the start of each section to help you avoid this mistake.
  • Select meaningful identifiers (names) for all variables and functions in your program.
  • Indent all code found within the main and all user-defined functions exactly two spaces.
  • Control-forcing statements such as exit, break, continue, and the use of multiple return statements in a single function are not acceptable practices according to course standards.

Course Programming and Documentation Standards Reminders (continued):

  • Do not single (or double) space the entire program, use blank lines when appropriate.
  • Consider making symbolic/defined constants to represent those values that do not change during the execution of the program.
  • There is no need to include example output with your submission.
  • Remove any diagnostic print statements from your code, even if they are commented out (inactive), unless you believe your program to be logically incorrect or incomplete as a way to demonstrate to your lab instructor how much of the problem you were able to solve and attempted to implement.

When you submit

Only the final attempt of a submission is kept for grading. All other submissions are over-written and cannot be recovered. You may make multiple submissions but only the last attempt is retained and graded.

  • Verify in the confirmation e-mail sent to you by the course that you have submitted the correct file (must be named hw07.c), to the correct assignment (hw07), and to the correct section.
  • Leave time prior to the due date to seek assistance should you experience difficulties completing or submitting this assignment.
  • All attempts to submit via a method other than through the guru server as set up during the first lab of the semester will be denied consideration.