T-rex
unknown
c_cpp
4 years ago
941 B
6
Indexable
#include <stdio.h> #define SIZE 50-38+1 void create(int left[], int s1, int right[], int s2, int sizes[SIZE][3]){ int i; for (i = 0; i < SIZE; i ++){ sizes[i][0] = i + 38; } for (i = 0; i < s1; i ++){ if (left[i] <= 50 && left[i] >= 38){ sizes[left[i] - 38][1] ++; } } for (i = 0; i < s2; i ++){ if (right[i] <= 50 && right[i] >= 38){ sizes[right[i] - 38][2] ++; } } } int main() { int left[7] = {43, 44, 45, 45, 45, 47, 47}; int right[6] = {38, 38, 43, 44, 45, 45}; int i, j; int sizes[SIZE][3] = {}; // fill with 0's create(left, 7, right, 6, sizes); // call the function with left, right, left's and right's length, and sizes for (i = 0; i < SIZE; i ++){ for (j = 0; j < 3; j ++){ printf("%d ", sizes[i][j]); } printf("\n"); } return 0; }
Editor is loading...