Thread: matrix!

  1. #1
    Registered User
    Join Date
    Jul 2014


    The program need to find mean of elements in columns which are divided by 3. And to print which colmn has the greater mean
    For matrix:
    7 9 5
    17 15 30
    29 34 60

    Program print: 0 12 45. The greater mean: 3 column.

    I wrote this code and it prints 0 12 45 idk how to find which column has greater mean?

    #include <stdio.h>
    #define max 50
    int main()
    {int n,m,i,j,k,d,br=0,suma;
    int a[max][max];
    int b[max][max];
        printf("Kolku redici i kolku koloni da imat matricite: \n");
        scanf("%d \n %d \n", &n,&m);
        for(i=0; i<m; i++)
            for(j=0; j<n; j++)
                scanf("%d", &a[i][j]);
    printf("Prvata matrica izgleda vaka: \n");
        for(i=0; i<m; i++)
            for(j=0; j<n; j++)
                printf("%d ", a[i][j]);
    for(i=0; i<n; i++)
        for(j=0; j<n; j++)
                suma+= a[j][i];
        int b=suma/br;
        printf("%d ", b);
      else {
            int q=suma;
        printf("%d \n", suma);}

  2. #2
    Registered User
    Join Date
    Jun 2005
    When you compute the mean for each column, use another variable to record which column has the largest.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User zub's Avatar
    Join Date
    May 2014
    Just create array for means and find max value in it. By the way, why is array b[max][max]?
    Our goals are clear, tasks are defined! Let's work, comrades! -- Nikita Khrushchev

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-19-2014, 07:32 PM
  2. reading a matrix and printing out the matrix
    By Lina_inverse in forum C Programming
    Replies: 9
    Last Post: 10-23-2012, 04:09 PM
  3. adjacency matrix and sparse matrix
    By dpp in forum C Programming
    Replies: 3
    Last Post: 07-11-2010, 10:26 AM
  4. Need help in Matrix Addition & finding Inverse of a Matrix
    By ssatyan.129 in forum C Programming
    Replies: 6
    Last Post: 05-15-2009, 02:48 PM
  5. Matrix: Reloaded + Enter The Matrix (the game)
    By LuckY in forum A Brief History of
    Replies: 10
    Last Post: 04-18-2003, 12:35 AM