3 Replies - 220 Views - Last Post: 21 March 2013 - 06:52 PM Rate Topic: -----

#1 moins1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-March 13

problem displaying result

Posted 20 March 2013 - 06:18 PM

hi,
I have a problem with this program
normally,i should have something after treatement like that
4 -0.25 0.25
-0.25 4 0.75
0.25 0.75 1
but the program show
4.00 -0.25 0.25
-0.25 4.25 0.65
0.25 0.65 3.5
I don't konw where is the mistake :(/>
Any help please
 int i,k,p;
 float R[N],D[N][N];

   for(k=1;k<4;k++)
{
     for(p=1;p<4;p++)
        {
           R[p]=D[p][p]*A[p][k];
           A[k][k]=A[k][k]-A[k][p]*R[p];
           

       }
       for(i=k+1;i<4;i++)
       {
         for(p=1;p<k;p++)
       {
           A[i][k]=A[i][k]-A[i][p]*R[p];
       }
}

           
 



Is This A Good Question/Topic? 0
  • +

Replies To: problem displaying result

#2 Switters  Icon User is offline

  • D.I.C Head

Reputation: 25
  • View blog
  • Posts: 110
  • Joined: 03-June 12

Re: problem displaying result

Posted 20 March 2013 - 07:17 PM

Please post the whole program, not just a snippet.

You also should adopt more descriptive variable names, and an indentation style--this code is incomplete and largely unreadable / unintelligible to anyone other than yourself, so providing feedback is a challenge.
Was This Post Helpful? 0
  • +
  • -

#3 moins1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-March 13

Re: problem displaying result

Posted 21 March 2013 - 05:44 PM

hi thanks for replying,i have resolved this problem but i have another one
here the function
void calculate (Matrice A, int m, int n)
{
    int i,j,k;
    float V[10][10],U[10][10];
   int C[3]={0,0,1};// table that contains indice

   for(j=1;j<n+1;j++)
{
     for(k=1;k<j;k++)
        {
           V[k][k]=A[k][k]*A[k][j];
           U[k][k]=A[j][k]*A[k][k];
           A[j][j]=A[j][j]-U[k][k]*A[k][j];

       }
       for(i=j+1;i<m+1;i++)
       {

         for(k=max(C[i],C[j]) ;k<j;k++)
       {
           A[i][j]=A[i][j]-U[k][k]*A[k][i];
           A[j][i]=A[j][i]-A[i][k]*V[k][k];
       }

               A[i][j]=(A[i][j])/A[j][j];
               A[j][i]=(A[j][i])/A[j][j];

       }
}
}


my problem is when i compile it show like that
2.00	 1.50	-5764606857314304.00	
 2.50	-7.50	-2305842850299904.00	
-5764606857314304.00	-3843071238209536.00	2692520199722279800000000.00	




i don't konw what is the problem !! help
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3461
  • View blog
  • Posts: 10,669
  • Joined: 05-May 12

Re: problem displaying result

Posted 21 March 2013 - 06:52 PM

Assuming the values are correct, what's wrong with the output? Were you expecting the columns to line up magically?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1