$ mkdir ~/cs170/tests $ mkdir ~/cs170/tests/final $ cd ~/cs170/test/final
This portion of the test is worth 30 total points. In addition to this file, you may only access the C++ documentation website and the Qt documentation documentation website. NO OTHER WEBSITES ARE PERMITTED. You are also not allowed to access any personal files in your CS account. As usual, you are not allowed to directly copy any code from the Internet or another individual. You should also follow all coding standards discussed thus far.
Create a Qt program called greyscale. This program should create a grey gradient across the entire window.
A color value is grey if it's red, green, and blue values are all the same value. To figure out the color values for a particular pixel, compute the distance the pixel is from \((0, 0)\). Compute the percentage of the distance to \((WIDTH, HEIGHT)\), and use this as the percentage of the maximum color value to use for R, G, and B.
To change the color you draw in, you need to change the color of the pen of the painter. You need to create a QColor object, and pass it to the setPen method of the painter.
(10 points)
Create a file called Question10.cc in your directory.
Inside this file, write a RECURSIVE function
called bool isSortedAscending(int * anArray, int size)
.
This function takes an array of at least size.
number of integers. This function should return true if the
provided array is sorted in ascending order. It should
return false in all other circumstances.
int myArray[] = {0, 1, 2, 3}; printBool(isSortedAscending(myArray, 4)); // Prints True int mySecondArray[] = {0, 1, 2, 3, 4, 3}; printBool(isSortedAscending(mySecondArray, 6)); // Prints False printBool(isSortedAscending(mySecondArray, 5)); // Prints True
(10 points)