Stallwars
23-01-2010, 15:22
Raga ho provato a sviluppare un programma per il calcolo del determinante di una matrice max 1000 per 1000 ma mi da errore: ARITHMETIC ON POINTER AN INCOMPLETE TYPE... cioè??
Help!!! xD :D :help:
Eccovi il codice se può servire... L'errore me lo da sulle righe 119 e 139.
Credo scambi la moltiplicazione per un puntatore ma nn so come risolvere.
#include<stdio.h>
void load(int *h, int x, int y);
long determinante (long X[][], int x);
long totdet(long X[][], long mx, int h);
void
main ()
{
long M[1000][1000];
int i=1, j=1, x, y;
printf("\t\tCALCOLO DETERMINANTE MATRICI QUADRATE.\n
\t\tIL CALCOLO VIENE ESEGUITO SU ELEMENTI\n
\t\tCOMPRESI TRA -3000 e 3000.\n\n
\t\tDIMENSIONE MASSIMA MATRICE: 1000x1000\n\n");
//CARICAMENTO GRANDEZZA MATRICE
do
{
if(i<1||i>1000) printf("\n\nIl valore inserito e' errato, inserire un valore compreso tra 1 e 1000.");
printf("\n\n\n*Inserire il numero di righe (e colonne) della matrice: ");
scanf("%d",&i);
}
while(i<1||i>1000);
j=i;
printf("\n\n\n\n\n");
do
{
for(x=0; x<i; x++)
{
load(&M[y][x], y, x);
}
y++;
}
while(y<j);
printf("\n\n\n\t\tIl determinante della matrice è: %ld", determinante(M ,x ));
system("PAUSE");
}
_______________FINE MAIN_______________
void
load(int *h, int y, int x)
{
do
{
if(*h<-3000||*h>3000) printf("\n\nINSERISCI UN VALORE CORRETTO\n\n");
printf("***Inserire l'elemento di indici %d,%d della matrice: ", y+1, x+1);
scanf("%d",&*h);
}
while(*h<-3000||*h>3000);
}
long
determinante(long X[][], int x)
{
int h, DET=1, TOTDET;
for(h=0;h<x-1;h++)
{
DET=X[h][h]*(DET); /*vedi teorema di laplace*/
}
h++;
TOTDET=totdet(X , DET, h);
return TOTDET;
}
long
totdet(long X[][], long mx, int h)
{
return mx*(((X[h][h])*(X[h+1][h+1]))-((X[h+1][h])*(X[h][h+1])));
}
Help!!! xD :D :help:
Eccovi il codice se può servire... L'errore me lo da sulle righe 119 e 139.
Credo scambi la moltiplicazione per un puntatore ma nn so come risolvere.
#include<stdio.h>
void load(int *h, int x, int y);
long determinante (long X[][], int x);
long totdet(long X[][], long mx, int h);
void
main ()
{
long M[1000][1000];
int i=1, j=1, x, y;
printf("\t\tCALCOLO DETERMINANTE MATRICI QUADRATE.\n
\t\tIL CALCOLO VIENE ESEGUITO SU ELEMENTI\n
\t\tCOMPRESI TRA -3000 e 3000.\n\n
\t\tDIMENSIONE MASSIMA MATRICE: 1000x1000\n\n");
//CARICAMENTO GRANDEZZA MATRICE
do
{
if(i<1||i>1000) printf("\n\nIl valore inserito e' errato, inserire un valore compreso tra 1 e 1000.");
printf("\n\n\n*Inserire il numero di righe (e colonne) della matrice: ");
scanf("%d",&i);
}
while(i<1||i>1000);
j=i;
printf("\n\n\n\n\n");
do
{
for(x=0; x<i; x++)
{
load(&M[y][x], y, x);
}
y++;
}
while(y<j);
printf("\n\n\n\t\tIl determinante della matrice è: %ld", determinante(M ,x ));
system("PAUSE");
}
_______________FINE MAIN_______________
void
load(int *h, int y, int x)
{
do
{
if(*h<-3000||*h>3000) printf("\n\nINSERISCI UN VALORE CORRETTO\n\n");
printf("***Inserire l'elemento di indici %d,%d della matrice: ", y+1, x+1);
scanf("%d",&*h);
}
while(*h<-3000||*h>3000);
}
long
determinante(long X[][], int x)
{
int h, DET=1, TOTDET;
for(h=0;h<x-1;h++)
{
DET=X[h][h]*(DET); /*vedi teorema di laplace*/
}
h++;
TOTDET=totdet(X , DET, h);
return TOTDET;
}
long
totdet(long X[][], long mx, int h)
{
return mx*(((X[h][h])*(X[h+1][h+1]))-((X[h+1][h])*(X[h][h+1])));
}