#include "IdanLib.h"
#include <stdio.h>

#define M 8
#define N 10

int ColumnSum(int mat[][N], unsigned short row_size ,unsigned short column)
{
    unsigned short counter;
    int sum = ZERO;
    for (counter = ZERO; counter < row_size; counter++)
    {
        sum += mat[counter][column];
    }

    return (sum);
    
}

int RowSum(int mat[][N], unsigned short col_size ,unsigned short row)
{
    unsigned short counter;
    int sum = ZERO;
    for (counter = ZERO; counter < col_size; counter++)
    {
        sum += mat[row][counter];
    }

    return (sum);
}

unsigned short SumArray(unsigned short array[], unsigned short start, unsigned short end)
{
    int sum = ZERO,
        counter;
    for (counter = start; counter < end; counter++)
    {
        sum += array[counter];
    }

    return (sum);    
}

unsigned short IndexOfRangeMaxSum(int vector, unsigned short vector_size, unsigned short count_index)
{
    int index_max_sum,
        max_sum = ZERO,
        sum;
    unsigned short new_size = vector - count_index;
    unsigned short counter;
    for (counter = ZERO; counter < new_size; counter++)
    {
        sum = SumArray(vector, counter, counter + count_index);
        if (sum > max_sum)
        {
            sum = max_sum;
            index_max_sum = counter;
        }
    }
    
    return (index_max_sum);
}

void SumOfNumberInRows(int mat[M][N], int sum_row[M], int number)
{
    unsigned short counter;
    unsigned int area = N * M;
    for ( counter = ZERO; counter < area; counter++)
    {
        sum_row[counter / N] += (mat[counter / N][counter % N] == number);
    }
}

void SumOfNumberInColumns(int mat[M][N], int sum_col[N], int number)
{
    unsigned short counter;
    unsigned int area = N * M;
    for ( counter = ZERO; counter < area; counter++)
    {
        sum_col[counter % N] += (mat[counter / N][counter % N] == number);
    }
}


void main(void)
{
    unsigned int L;
    int mat[M][N] = { ZERO };
    int sum_row[M] = { ZERO };
    int sum_col[N] = { ZERO };


}