Question: C Code - Array, searching and sorting Skeleton Code: #include #define MAX_PIXELS 20 int main(void) { int n, // number of pixels constA, constB, constC,
C Code - Array, searching and sorting

Skeleton Code:
#include#define MAX_PIXELS 20 int main(void) { int n, // number of pixels constA, constB, constC, constD; scanf("%d %d %d %d %d", &n, &constA, &constB, &constC, &constD); return 0; }
Test Data: http://www.comp.nus.edu.sg/~cs1010/practice/2017s1/Practice-S12P06/testdata/
Objective: Problem solving Task statement The most common way of representing pixels (picture elements) is to use the RGB (red, green and blue) values, which range from 0 to 255 Given a list of pixels represented by their RGB values, we may define similarity as follows: A list is of similarity measure D if for all pixels in this list, where A, B, C and D are integer constants, r, g, and b are the RGB values for the pixel, and rmin, gmin, and bmin are the minimum R-, G-, and B-values among all the pixels in this list. (Note: More than one pixel may have the same RGB value.) Given the RGB values of n pixels, and the integer constants A, B, C, and D, we want to find the size of the largest sublist of pixels with similarity D Write a program pixels.c to solve this problem The first line of the input contains 5 integers: n, A, B, C, and D (where 1 S n s 20, 1 s A, B, C S 10000, and 1 s D s 10000000) The following n lines each contains three integers r, g and b (where 0 Sr, g, b 255) representing the RGB values of a pixel Your program should output the size of the largest sublist of similarity measure D Example For example, given a list of 5 pixels: and given also that A = B = C= 1, and D = 5 if we pick a sublist that contains the first, second and fourth pixels (3,7,5), (4,8,6), (4,9,7)], then rmin = 3, gmin-7, and bmin-5 For the first pixel (3,7,5), the measure is 1x(3-3) + 1x(7-7) + 1x(5-5-0. For the second pixel (4,8,6), the measure is 1x(4-3) 1x(8-7) 1x(6-5) 3. For the fourth pixel (4,9,7), the measure is 1x(4-3) + 1x(9-7) + 1x(7-5) = 5 Objective: Problem solving Task statement The most common way of representing pixels (picture elements) is to use the RGB (red, green and blue) values, which range from 0 to 255 Given a list of pixels represented by their RGB values, we may define similarity as follows: A list is of similarity measure D if for all pixels in this list, where A, B, C and D are integer constants, r, g, and b are the RGB values for the pixel, and rmin, gmin, and bmin are the minimum R-, G-, and B-values among all the pixels in this list. (Note: More than one pixel may have the same RGB value.) Given the RGB values of n pixels, and the integer constants A, B, C, and D, we want to find the size of the largest sublist of pixels with similarity D Write a program pixels.c to solve this problem The first line of the input contains 5 integers: n, A, B, C, and D (where 1 S n s 20, 1 s A, B, C S 10000, and 1 s D s 10000000) The following n lines each contains three integers r, g and b (where 0 Sr, g, b 255) representing the RGB values of a pixel Your program should output the size of the largest sublist of similarity measure D Example For example, given a list of 5 pixels: and given also that A = B = C= 1, and D = 5 if we pick a sublist that contains the first, second and fourth pixels (3,7,5), (4,8,6), (4,9,7)], then rmin = 3, gmin-7, and bmin-5 For the first pixel (3,7,5), the measure is 1x(3-3) + 1x(7-7) + 1x(5-5-0. For the second pixel (4,8,6), the measure is 1x(4-3) 1x(8-7) 1x(6-5) 3. For the fourth pixel (4,9,7), the measure is 1x(4-3) + 1x(9-7) + 1x(7-5) = 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
