Help for Homework!

This is a discussion on Help for Homework! within the C Programming forums, part of the General Programming Boards category; Hello, here is two programs; 1.Given matrix NxM. Get sequence b1 ,.,bn , where bk the largest element of row ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    20

    Help for Homework!

    Hello, here is two programs;
    1.Given matrix NxM. Get sequence b1 ,.,bn , where bk the largest element of row k.
    2. Enter an integer N. Enter a whole number N x M to the table. The following table each row to find the minimum number, then the maximum. Print found in the number of coordinates (row, column).

    For first i have tried this:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #define SIZE 10
    void ivesti_matrica( int matrica[][3], int eiluciu_sk);
    void spausdinti_matrica( int matrica[][3], int eiluciu_sk);
    void burbulas(int matrica[][3],  int burbulas);
    int main()
    {    int a [3][3];
        printf("Prasom ivedineti matricos elementus \n");
        ivesti_matrica(a,3);
        printf("Ivesta matrica: \n");
        spausdinti_matrica(a,3);
        system("pause");
        return 0;}
    void ivesti_matrica( int matrica[][3], int eiluciu_sk)
    {
         int i,j;
         for (i=0;i<eiluciu_sk;i++)
            for (j=0;j<eiluciu_sk;j++)
             {
              printf("Iveskite a[%d,%d]elementa ",i+1,j+1);
              scanf("%d",&matrica[i][j]);
              }}
      void spausdinti_matrica( int matrica[][3], int eiluciu_sk)
    {     int i,j;
         for (i=0;i<eiluciu_sk;i++)
           {
            for (j=0;j<eiluciu_sk;j++)
             printf("%4d",matrica[i][j]);
             printf("\n");}
    void burbulas(int matrica[][3] , int burbulas);
        printf ("Surusiuotas masyvas: \n");
        for (i=0;i<SIZE;i++)
        for (j=0;j<SIZE;i==);
         printf ("%4d",matrica[i][j]);
         printf("\n");
         system("pause");
         return 0;}
    is it correct?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    Apart from all the dumb syntax errors in the last function, it might be OK.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by alionas View Post
    is it correct?
    Nope.

  4. #4
    Registered User
    Join Date
    Nov 2010
    Posts
    20
    so could you help me to fix it?

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    I found most of "your" code (the bit that is syntactically correct) on Page 12 of this powerpoint presentation

    But then again, burbulas() is just doing the same job as spausdinti_matrica()
    I mean, you could just COPY/PASTE it and change the name, and be done with it.

    Are you by any chance trying to turn a[3][3] into a[SIZE][SIZE] ?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21