The unified diff between revisions [56e5a93f..] and [45197df6..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'aca319/lab8q1.c'
#
#
# patch "aca319/lab8q1.c"
# from [8ff5f24b4a00f634973be72edd4ab692d98bb232]
# to [7a174ce6c938185e31421514b55073736fae82fe]
#
============================================================
--- aca319/lab8q1.c 8ff5f24b4a00f634973be72edd4ab692d98bb232
+++ aca319/lab8q1.c 7a174ce6c938185e31421514b55073736fae82fe
@@ -94,11 +94,11 @@ int
}
int
-int_compare(const void *a, const void *b)
+char_compare(const void *a, const void *b)
{
- int c = *(int *)a;
- int d = *(int *)b;
- return d - c;
+ unsigned char c = *(int *)a;
+ unsigned char d = *(int *)b;
+ return c - d;
}
void
@@ -116,7 +116,7 @@ median(const unsigned char **pixels, int
for (i=0;i<count;i++) {
s[i] = *(pixels[i] + p);
}
- qsort(s, count, sizeof(unsigned char), int_compare);
+ qsort(s, count, sizeof(unsigned char), char_compare);
if (count % 2) {
/* average the two middle values to get median */
median = (s[count/2] + s[(count/2)+1]) / 2;