Ir ao conteúdo
  • Cadastre-se

[error] invalid types 'long double[int]' for array subscript


Ir à solução Resolvido por Pedro Math.pi,

Posts recomendados

Boa tarde galera, estou com o erro [error] invalid types 'long double[int]' for array subscript no meu programa e não consegui fazer funcionar, fiz a mesma coisa em outros programas e funcionou perfeitamente, se alguém puder ajudar ficarei grato.

//Exercicio 2//SOLUÇÃO DE SISTEMAS LINEARES TRIANGULARES #include <math.h>#include <iostream>#include <stdlib.h>#include <stdio.h>using namespace std;  int main(){//Solucao matriz triangular até 10x10//entrar com a ordem do sistema no valor da variável nint j, i;//Matriz triangular inferior a ser resolvida - Matriz Ldouble long L[10][10]={						{	8.170175640767010	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	}	,						{	-4.038186711461980	,	8.464881853557280	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	}	,						{	9.312120959626790	,	-16.317669766053000	,	-15.239259729281400	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	}	,						{	9.215736811758120	,	6.167303078818610	,	9.504041480066950	,	3.090726235660050	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	}	,						{	-33.919439765532700	,	-11.666786892686800	,	-0.851641525068743	,	-23.601033284769800	,	8.863773100094720	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	}	,						{	-20.591086526279600	,	23.527179863787000	,	-17.358823238377200	,	-11.228234077635400	,	6.405155980871840	,	-3.071628329649960	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	}	,						{	-22.359510830717500	,	-0.505318767460456	,	-9.719212745026620	,	-9.205178122916290	,	-15.314210050801600	,	5.084423538318750	,	-11.436599887166900	,	0.000000000000000	,	0.000000000000000	,	0.000000000000000	}	,						{	6.235226647790050	,	25.385015183687500	,	3.871646063375990	,	6.227341818038560	,	11.785854233290300	,	-3.697609156208370	,	-27.152030603826900	,	43.249732214360300	,	0.000000000000000	,	0.000000000000000	}	,						{	22.812401990050100	,	-6.595426955065370	,	-15.408195501023800	,	14.618626909540600	,	-10.197474603451500	,	3.562543912888930	,	14.127517695985300	,	-18.102576839800900	,	27.592336467284100	,	0.000000000000000	}	,						{	-5.071018275014310	,	9.145952382903750	,	15.127830956485800	,	4.662495383765920	,	-9.370710899137920	,	6.827234617698460	,	13.454100478661800	,	-28.772261754312000	,	18.977669896345800	,	3.658944604405920	}					};//Vetor Soluçao Bdouble long B[10][1]={					  {41.227304771574758},					  {31.105003506037598},					  {21.846078798415505},					 {-18.550767330302328},					 {-18.198467913583865},					 {-11.199319375482059},					 { 10.845530282456821},					 { -1.680622984971126},					  { 7.746881118481327},					 {-24.762274626297412}				};				//AS MATRIZES ACIMA TEM PRECISÃO ESTENDIDA, OS COMANDOS ABAIXO FAZEM UMA MATRIZ SEMELHANTE A DIGITADA,//PORÉM COM PRECISÃO SIMPLES				float L2[10][10], B2[i][0];for(i=0; i<10; i++){         for(j=0; j<10; j++)         {          L2[i][j] = L[i][j];         }         }for(i=0; i<10; i++){                 B2[i][0] = B[i][0];         }												//Calculo do vetor solucao com precisão estendidadouble long x[10];x[0]=B[0][0]/L[0][0];x[1]=(B[1][0]-L[1][0]*x[0])/L[1][1];x[2]=(B[2][0]-L[2][0]*x[0]-L[2][1]*x[1])/L[2][2];x[3]=(B[3][0]-L[3][0]*x[0]-L[3][1]*x[1]-L[3][2]*x[2])/L[3][3];x[4]=(B[4][0]-L[4][0]*x[0]-L[4][1]*x[1]-L[4][2]*x[2]-L[4][3]*x[3])/L[4][4];x[5]=(B[5][0]-L[5][0]*x[0]-L[5][1]*x[1]-L[5][3]*x[2]-L[5][4]*x[3]-L[5][5]*x[4])/L[5][5];x[6]=(B[6][0]-L[6][0]*x[0]-L[6][1]*x[1]-L[6][2]*x[2]-L[6][3]*x[3]-L[6][4]*x[4]-L[6][5]*x[5])/L[6][6];x[7]=(B[7][0]-L[7][0]*x[0]-L[7][1]*x[1]-L[7][2]*x[2]-L[7][3]*x[3]-L[7][4]*x[4]-L[7][5]*x[5]-L[7][6]*x[6])/L[7][7];x[8]=(B[8][0]-L[8][0]*x[0]-L[8][1]*x[1]-L[8][2]*x[2]-L[8][3]*x[3]-L[8][4]*x[4]-L[8][5]*x[5]-L[8][6]*x[6]-L[8][7]*x[7])/L[8][8];x[9]=(B[9][0]-L[9][0]*x[0]-L[9][1]*x[1]-L[9][2]*x[2]-L[9][3]*x[3]-L[9][4]*x[4]-L[9][5]*x[5]-L[9][6]*x[6]-L[9][7]*x[7]-L[9][8]*x[8])/L[9][9];//Calculo do vetor solucao com precisão simplesfloat x2[10];x2[0]=B[0][0]/L2[0][0];x2[1]=(B[1][0]-L2[1][0]*x2[0])/L2[1][1];x2[2]=(B[2][0]-L2[2][0]*x2[0]-L2[2][1]*x2[1])/L2[2][2];x2[3]=(B[3][0]-L2[3][0]*x2[0]-L2[3][1]*x2[1]-L2[3][2]*x2[2])/L2[3][3];x2[4]=(B[4][0]-L2[4][0]*x2[0]-L2[4][1]*x2[1]-L2[4][2]*x2[2]-L2[4][3]*x2[3])/L2[4][4];x2[5]=(B[5][0]-L2[5][0]*x2[0]-L2[5][1]*x2[1]-L2[5][3]*x2[2]-L2[5][4]*x2[3]-L2[5][5]*x2[4])/L2[5][5];x2[6]=(B[6][0]-L2[6][0]*x2[0]-L2[6][1]*x2[1]-L2[6][2]*x2[2]-L2[6][3]*x2[3]-L2[6][4]*x2[4]-L2[6][5]*x2[5])/L2[6][6];x2[7]=(B[7][0]-L2[7][0]*x2[0]-L2[7][1]*x2[1]-L2[7][2]*x2[2]-L2[7][3]*x2[3]-L2[7][4]*x2[4]-L2[7][5]*x2[5]-L2[7][6]*x2[6])/L2[7][7];x2[8]=(B[8][0]-L2[8][0]*x2[0]-L2[8][1]*x2[1]-L2[8][2]*x2[2]-L2[8][3]*x2[3]-L2[8][4]*x2[4]-L2[8][5]*x2[5]-L2[8][6]*x2[6]-L2[8][7]*x2[7])/L2[8][8];x2[9]=(B[9][0]-L2[9][0]*x2[0]-L2[9][1]*x2[1]-L2[9][2]*x2[2]-L2[9][3]*x2[3]-L2[9][4]*x2[4]-L2[9][5]*x2[5]-L2[9][6]*x2[6]-L2[9][7]*x2[7]-L2[9][8]*x2[8])/L2[9][9];         //CALCULO NORMA 2 COM PRECISAO estendida         long double aux=0, norma_est;		for (i=0; i<10; i++)			aux+=pow(x[i][0],2);	norma_est = sqrt(aux);	cout <<"Norma Precisao estendida = ";		printf("%15.15Lf",norma_est);	cout <<endl;         //CALCULO NORMA 2 COM PRECISAO Simples         float aux1=0, norma_simples;		for (i=0; i<10; i++)			aux1+=pow(x2[i][0],2);	norma_simples = sqrt(aux1);	cout <<"Norma Precisao simples = ";		printf("%15.15f",norma_simples);	cout <<endl;// IMPRESSÃO OS RESULTADOS:	cout<<"Solucao Sistema triangular Inferior: "<<endl;for(i=0; i<10; i++)	{		printf("X %i", i+1);		printf("= %10.15Lf \n", x[i]);							cout<<endl<<"X"<<i+1<<"= "<<x[i]<<endl;	}//Matriz triangular superior a ser resolvida - Matriz U//Entre com a ordem do sitema no valor da variavel n1/*float U[10][10]={				{0, 0, 0, 0, 0, 0, 5, -2, 6, 1},				{0, 0, 0, 0, 0, 0, 0, 3, 7, -4},				{0, 0, 0, 0, 0, 0, 0, 0, 4, 5},				{0, 0, 0, 0, 0, 0, 0, 0, 0, 2},				{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},				{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},				{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},				{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},				{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},				{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}				};								//Vetor Soluçao Dfloat D[10][1]={				{1},				{-2},				{28},				{8},				{0},				{0},				{0},				{0},				{0},				{0}				};//Calculo do vetor solucao Xx[9]=D[9][0]/U[9][9];x[8]=(D[8][0]-U[8][9]*x[9])/U[8][8];x[7]=(D[7][0]-U[7][8]*x[8] + U[7][9]*x[9])/U[7][7];x[6]=(D[6][0]-U[6][7]*x[7] + U[6][8]*x[8] + U[6][9]*x[9] )/U[6][6];x[5]=(D[5][0]-U[5][6]*x[6] + U[5][7]*x[7] + U[5][8]*x[8] + U[5][9]*x[9] )/U[5][5];x[4]=(D[4][0]-U[4][5]*x[5] + U[4][6]*x[6] + U[4][7]*x[7] + U[4][8]*x[8] + U[4][9]*x[9] )/U[4][4];x[3]=(D[3][0]-U[3][4]*x[4] + U[3][5]*x[5] + U[3][6]*x[6] + U[3][7]*x[7] + U[3][8]*x[8] + U[3][9]*x[9])/U[3][3];x[2]=(D[2][0]-U[2][3]*x[3] + U[2][4]*x[4] + U[2][5]*x[5] + U[2][6]*x[6] + U[2][7]*x[7] + U[2][8]*x[8]+ U[2][9]*x[9])/U[2][2];x[1]=(D[1][0]-U[1][2]*x[2] + U[1][3]*x[3] + U[1][4]*x[4] + U[1][5]*x[5] + U[1][6]*x[6] + U[1][7]*x[7] + U[1][8]*x[8]+ U[1][9]*x[9])/U[1][1];x[0]=(D[0][0]-U[0][1]*x[2] + U[0][2]*x[2] + U[0][3]*x[3] + U[0][4]*x[4] + U[0][5]*x[5] + U[0][6]*x[6] + U[0][7]*x[7] + U[0][8]*x[8]+ U[0][9]*x[9])/U[0][0];			cout<<endl<<"Solucao Sistema triangular Superior: "<<endl;for(i=0; i<10; i++)	{	cout<<endl<<"X"<<i<<"= "<<x[i]<<endl;	}*/return 0;	}		
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Ebook grátis: Aprenda a ler resistores e capacitores!

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!