T-rex

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
945 B
1
Indexable
Never

#include <stdio.h>
#define SIZE 50-38+1

void create(int left[], int s1, int right[], int s2, int sizes[SIZE][3]){
    int i, j;
    
    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;
}