С++. What is faster and why?
void test1(unsigned char **matrix) { unsigned int start = clock(); int counter = 0; for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { if(matrix[i][j] >= 128) { counter++; } } } unsigned int end = clock(); printf("%d\n", end-start); } void test2(unsigned char **matrix) { unsigned int start = clock(); int counter = 0; for(int j = 0; j < N; j++) { for(int i = 0; i < N; i++) { if(matrix[i][j] >= 128) { counter++; } } } unsigned int end = clock(); printf("%d\n", end-start); } void test3(unsigned char **matrix) { unsigned int start = clock(); int counter = 0; for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { counter+=matrix[i][j]>>7; } } unsigned int end = clock(); printf("%d\n", end-start); } int main(int argc, char **argv) { unsigned char **matrix = (unsigned char **)malloc(N * sizeof(unsigned char *)); for(int i = 0; i < N; i++) { matrix[i] = (unsigned char *)malloc(N * sizeof(unsigned char *)); for(int j = 0; j < N; j++) { matrix[i][j] = rand() % 255; } } test1(matrix); test2(matrix); test3(matrix); return 0; }