代写C++代码 代做C++程序 C++辅导 C++教学

C++网络家教 远程写代码 在线Debug 讲解答疑 不是中介,本人直接写

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

CS 158/159 

This assignment is worth 15 points and will be due Monday November 23, 2015 at 11:00pm. All 

assignment deadlines are firm and the ability to submit your assignment will be disabled after the 

deadline elapses. No late work will be accepted. You are encouraged to start this assignment as soon as 

possible so that you have ample time to seek assistance should you experience difficulties completing or 

submitting this assignment. 

 

This programming assignment does not have a single solution, and the assignment you submit must be 

your own original work. Collaboration with other students is not permitted on homework assignments. 

Any submission may be processed with comparison software and the results will be used to detect 

unacceptable collaboration between individuals. If you need assistance, you should only consult course 

staff regarding your program. 

 

Your program must adhere to the course programming standards (available in the course packet and in 

Blackboard). Please review this document before submitting your assignment, because failure to adhere 

to it will result in a reduction in points. Your program must include the designated program header 

(~cs15x/student/hdrProg) at the top of the program (which can be inserted in vi using the hp shortcut 

while in command mode). The header must include an appropriate description of your program and must 

contain your official Purdue career account e-mail address. Also note that course standards prohibit the 

use of advanced programming concepts not yet introduced in the course, unless otherwise specified. 

 

Each of the example executions provided below represents a single execution of the program. Your 

program must accept input and produce output exactly as demonstrated in the example executions. Your 

program will be tested with the data seen in the examples below and an unknown number of additional 

tests making use of reasonable data. Do not include any example outputs with your submission. 

 

A single program file (with the .c extension) must be submitted electronically via the guru server. An 

example submission was conducted during the first week in lab00. Any attempts to submit via another 

method will be denied consideration. You may make multiple submissions before the deadline, but only 

the last attempt is retained and graded. All previous submissions will be over-written and cannot be 

recovered. The submission script will reject the submission of any file that does not compile. A program 

must compile to be considered for partial credit. You should always check the confirmation e-mail you 

receive after a submission to verify that you have submitted the correct file, to the correct assignment, 

and to the correct lab section. If you have a concern regarding how to submit work, please visit course 

staff prior to the assignment deadline. 

 

   Problem: The user will enter up to 25 integer values to be stored in an array starting at index zero. Next, 

the user will enter two values that represent the starting and ending index values of the array. Take the 

first value of this subset (at the starting index) and determine how many values in the range (from start 

to end, inclusive of both end points) are multiples of the first value. 

 

Example Execution #1: 

Enter data value for index #0 or -1 to exit: 3 

Enter data value for index #1 or -1 to exit: 4 

Enter data value for index #2 or -1 to exit: 5 

Enter data value for index #3 or -1 to exit: 6 

Enter data value for index #4 or -1 to exit: 3 

Enter data value for index #5 or -1 to exit: 9 

Enter data value for index #6 or -1 to exit: 12 

Enter data value for index #7 or -1 to exit: 4 

Enter data value for index #8 or -1 to exit: 7 

Enter data value for index #9 or -1 to exit: 8 

Enter data value for index #10 or -1 to exit: 9 

Enter data value for index #11 or -1 to exit: -1 

 

Enter starting index: 1 

Enter ending index: 10 

 

Total data in the array: 11 

Data range specified by the user: [1, 10] 

First value in range: 4 

Total multiples of above value in the range: 4 

 

Example Execution #2: 

Enter data value for index #0 or -1 to exit: 4 

Enter data value for index #1 or -1 to exit: 5 

Enter data value for index #2 or -1 to exit: 4 

Enter data value for index #3 or -1 to exit: 5 

Enter data value for index #4 or -1 to exit: 4 

Enter data value for index #5 or -1 to exit: -1 

 

Enter starting index: 2 

Enter ending index: 4 

 

Total data in the array: 5 

Data range specified by the user: [2, 4] 

First value in range: 4 

Total multiples of above value in the range: 2 

 

   Example Execution #3 (a -1 value is not needed to exit input when the array is filled to capacity): 

Enter data value for index #0 or -1 to exit: 2 

Enter data value for index #1 or -1 to exit: 3 

Enter data value for index #2 or -1 to exit: 4 

Enter data value for index #3 or -1 to exit: 5 

Enter data value for index #4 or -1 to exit: 6 

Enter data value for index #5 or -1 to exit: 7 

Enter data value for index #6 or -1 to exit: 8 

Enter data value for index #7 or -1 to exit: 2 

Enter data value for index #8 or -1 to exit: 3 

Enter data value for index #9 or -1 to exit: 4 

Enter data value for index #10 or -1 to exit: 5 

Enter data value for index #11 or -1 to exit: 6 

Enter data value for index #12 or -1 to exit: 7 

Enter data value for index #13 or -1 to exit: 8 

Enter data value for index #14 or -1 to exit: 2 

Enter data value for index #15 or -1 to exit: 3 

Enter data value for index #16 or -1 to exit: 4 

Enter data value for index #17 or -1 to exit: 5 

Enter data value for index #18 or -1 to exit: 6 

Enter data value for index #19 or -1 to exit: 7 

Enter data value for index #20 or -1 to exit: 8 

Enter data value for index #21 or -1 to exit: 2 

Enter data value for index #22 or -1 to exit: 3 

Enter data value for index #23 or -1 to exit: 4 

Enter data value for index #24 or -1 to exit: 5 

 

Enter starting index: 10 

Enter ending index: 20 

 

Total data in the array: 25 

Data range specified by the user: [10, 20] 

First value in range: 5 

Total multiples of above value in the range: 2 

 

Example Execution #4 (values in the data set must be positive): 

Enter data value for index #0 or -1 to exit: 0 

 

Error! Data must be positive!! 

 

Enter data value for index #0 or -1 to exit: 3 

Enter data value for index #1 or -1 to exit: 4 

Enter data value for index #2 or -1 to exit: 5 

Enter data value for index #3 or -1 to exit: -4 

 

Error! Data must be positive!! 

 

Enter data value for index #3 or -1 to exit: 6 

Enter data value for index #4 or -1 to exit: 7 

Enter data value for index #5 or -1 to exit: -1 

 

Enter starting index: 3 

Enter ending index: 3 

 

Total data in the array: 5 

Data range specified by the user: [3, 3] 

First value in range: 6 

Total multiples of above value in the range: 1 

 Example Execution #5 (input validation for starting and ending values demonstrated): 

Enter data value for index #0 or -1 to exit: 1 

Enter data value for index #1 or -1 to exit: 2 

Enter data value for index #2 or -1 to exit: 3 

Enter data value for index #3 or -1 to exit: 4 

Enter data value for index #4 or -1 to exit: 5 

Enter data value for index #5 or -1 to exit: 6 

Enter data value for index #6 or -1 to exit: 7 

Enter data value for index #7 or -1 to exit: 8 

Enter data value for index #8 or -1 to exit: 9 

Enter data value for index #9 or -1 to exit: 10 

Enter data value for index #10 or -1 to exit: -1 

 

Enter starting index: -4 

 

Error! Starting index must be non-negative! 

 

Enter starting index: 10 

 

Error! Starting index cannot exceed amount of data present! 

 

Enter starting index: 2 

Enter ending index: 1 

 

Error! Ending value cannot be less than starting value!! 

 

Enter ending index: 10 

 

Error! Ending index cannot exceed amount of data present! 

 

Enter ending index: 8 

 

Total data in the array: 10 

Data range specified by the user: [2, 8] 

First value in range: 3 

Total multiples of above value in the range: 3 

 

Example Execution #6: 

Enter data value for index #0 or -1 to exit: 13 

Enter data value for index #1 or -1 to exit: 17 

Enter data value for index #2 or -1 to exit: 19 

Enter data value for index #3 or -1 to exit: 23 

Enter data value for index #4 or -1 to exit: 29 

Enter data value for index #5 or -1 to exit: 31 

Enter data value for index #6 or -1 to exit: 37 

Enter data value for index #7 or -1 to exit: 41 

Enter data value for index #8 or -1 to exit: 43 

Enter data value for index #9 or -1 to exit: 11 

Enter data value for index #10 or -1 to exit: 7 

Enter data value for index #11 or -1 to exit: 3 

Enter data value for index #12 or -1 to exit: -1 

 

Enter starting index: 5 

Enter ending index: 11 

 

Total data in the array: 12 

Data range specified by the user: [5, 11] 

First value in range: 31 

Total multiples of above value in the range: 1   Additional Notes: 

●  Your program  is  expected  to  accept  input, validate  input, and produce output  in  the  same manner 

demonstrated in the example executions. 

●  The user will always enter a minimum of two integers (int) to create the data set. 

●  Be sure to test your program with 24 integers and the -1 value as the 25th

●  Course  standards prohibit  the use of programming concepts not  yet  introduced  in  lecture. For  this 

assignment you can consider all material in the first 8 chapters of the book, notes, and lectures. 


相关推荐