[ create a new paste ] login | about

Link: http://codepad.org/h3kPD2Iq    [ raw code | output | fork ]

C, pasted on Jun 30:
#include <stdio.h>

int main(void)
{
    int n, i, j;
    scanf("%d", &n);

    int sugar [n]  [n];

    for (i=0; i<n; i++)
    {
        for (j=0; j<n; j++)
        {
            scanf("%d", & sugar [i]  [j] );
        }
    }


    for (i=0; i<n; i++)
    {
        int maxval=0;
        for (j=0; j<n; j++)
        {
            if ( maxval<= sugar [i]  [j] ) { maxval= sugar [i]  [j]; }
        }

        printf("%d", maxval);
        if (i != n-1) { printf(" "); }
        else { printf("\n"); }
    }

    for (j=0; j<n; j++)
    {
        int minval=50001;
        for (i=0; i<n; i++)
        {
            if ( minval>= sugar [i]  [j] ) { minval= sugar [i]  [j]; }
        }

        printf("%d", minval);
        if (j != n-1) { printf(" "); }
        else { printf("\n"); }
    }


    return 0;
}


Output:
1
Segmentation fault


Create a new paste based on this one


Comments: