正在加载图片...
-6- Problem 3-Simple C(10 points) Your job is to write a program to calculate the integer quotient (i.e.,division in the style of C's/ operator applied to integers,which throws away any remainder)of two input values,which you may assume are both positive.You may not use the division operator.Instead,you need to simulate the division by repeated subtraction,counting the number of times the second input value can be subtracted from the first before the result goes negative.The output of this program is shown in the following sample run,which shows that the quotient of 50 divided by 15 is 3: Please enter a number to divided:50 Please enter a number to be divided into 50:15 The quotient is:3 Problem 4-Arrays(10 points) The last shall be first. -Matthew,20:15 Write a function RotateRight that takes two arguments-an array of values of type double and an integer indicating the effective size of that array-and that has the effect of shifting every element one position rightward toward the end of the array,with the exception of the last element,which gets moved to the initial position.For example,if the array values has the contents values 3.14 2.72 98.6 6.28 22.5 42.0 calling RotateRight(values,6); should shift the first five values one position to the right and move the value from the last position to the front,as follows: values 42.0 3.14 2.72 98.6 6.28 22.5– 6 – Problem 3—Simple C (10 points) Your job is to write a program to calculate the integer quotient (i.e., division in the style of C’s / operator applied to integers, which throws away any remainder) of two input values, which you may assume are both positive. You may not use the division operator. Instead, you need to simulate the division by repeated subtraction, counting the number of times the second input value can be subtracted from the first before the result goes negative. The output of this program is shown in the following sample run, which shows that the quotient of 50 divided by 15 is 3: Problem 4—Arrays (10 points) The last shall be first. — Matthew, 20:15 Write a function RotateRight that takes two arguments—an array of values of type double and an integer indicating the effective size of that array—and that has the effect of shifting every element one position rightward toward the end of the array, with the exception of the last element, which gets moved to the initial position. For example, if the array values has the contents 3.14 2.72 98.6 6.28 22.5 42.0 values calling RotateRight(values, 6); should shift the first five values one position to the right and move the value from the last position to the front, as follows: 42.0 3.14 2.72 98.6 6.28 22.5 values Please enter a number to divided: 50 Please enter a number to be divided into 50: 15 The quotient is: 3
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有