Προς το περιεχόμενο

Προτεινόμενες αναρτήσεις

Δημοσ.
#include <stdio.h>

#include <stdlib.h>

 

void araios( int *table, int r, int c );

 

int main(int argc, char *argv[])

{

int i,j,m,n;

 

int **table;

 

printf( "Give the table's rows: " );

 

scanf( "%d",&m );

 

printf( "Give the table's columns: " );

 

scanf( "%d",&n );

 

 

table = (int **)malloc( m * sizeof( int ));

 

for ( i=0; i<n; i++ )

 

{

*(table + i) =(int *)malloc( n * sizeof( int ) );

}

 

for ( i=0; i<m; i++ )

{

    

for ( j=0; j<n; j++ )

{

    

table[j] = 0;

 

printf( "%d",table[j] );

 

}

 

printf( "\n" );

 

}

araios( &table,m,n );

 

system("PAUSE");

 

return 0;

}

void araios( int *table,int r, int c )

{

int i=0,j=0,sum=0;

for ( i=0; i<r; i++ )

{

for ( j=0; j<c; j++ )

{

if ( table[j] == 0 )

{

sum +=1;

}

}

}

if ( sum > 0.8*m*n )

{

printf( "The table is sparce." );

else

{

printf( "The table is not sparce." );

}

}

}

 

 

 

Για να μην κουραστειτε να το διαβάσετε ο compiler μου χτυπάει εκεί που καλείται η συνάρτηση.
Δημοσ.

Άλλαξε αυτά

 

void araios( int **table, int r, int c );

....

araios(table,m,n ); //κλήση

 

 

void araios( int **table,int r, int c )
{
   ....
  if ( sum > 0.8*r*c )
        ...
}

 

 

 

και βάλε μια scanf στα for loops για να περνάς τα στοιχεία του πίνακα.

  • Like 1

Δημιουργήστε ένα λογαριασμό ή συνδεθείτε για να σχολιάσετε

Πρέπει να είστε μέλος για να αφήσετε σχόλιο

Δημιουργία λογαριασμού

Εγγραφείτε με νέο λογαριασμό στην κοινότητα μας. Είναι πανεύκολο!

Δημιουργία νέου λογαριασμού

Σύνδεση

Έχετε ήδη λογαριασμό; Συνδεθείτε εδώ.

Συνδεθείτε τώρα
  • Δημιουργία νέου...