Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by Dmitry ( 6 years ago )
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main (void)
{

    int n = 5, m = 5;

    srand(time(NULL));

    int array[n][m];

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < m; ++j){
            array[i][j] = rand() % 9 + 1;
        }
    }

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < m; ++j){
            printf("%d ", array[i][j]);
        }
        printf("\n");
    }

    int array_summ[m - 1];

    int restriction = 1;

    for (int i = 0; i < m; ++i){
        int temp = 0;
        for (int j = 0; j < n - restriction; ++j){
            temp += array[j][i];
        }
        array_summ[i] = temp;
        restriction++;
    }
   

    int max = 0;
    int max_indx = 0;

    for (int i = 0; i < m - 1; ++i){
        if(max < array_summ[i]) {
            max = array_summ[i];
            max_indx = i;
        }
    }

    printf ("MAX: %d, INDEX: %d", max, max_indx + 1);
    getchar ();
    return 0;
}

 

Revise this Paste

Parent: 107147
Your Name: Code Language: