I can show the code of this file.
Please  it is necessary to write the dimension of this square matrix, i.e. 
N=33, then the dimension of the matrix it will be 1089x1089, in this form 
the program was developped.

Here it goes the code:
Please , again, write N=33 to obtain a matrix 1089x1089... when you opening
this text file you will see the error message...

#include<stdlib>
#include<stdio>
#include<iostream>
#include<conio>
#include<math>
using namespace std;
        float f1(int k, float h)
           {
              float z= k*h;
              return(z);
           }
       /////////////////////////////////////////////////////////////////
        float f2(int k, float h)
           {
              float z= k*h+1;
              return(z);
           }
       /////////////////////////////////////////////////////////////////
        float f3(int k, float h)
           {
              float z= k*h;
              return(z);
           }
       /////////////////////////////////////////////////////////////////

        float f4(int k, float h)
           {
              float z=1+ k*h;
              return(z);
           }
       /////////////////////////////////////////////////////////////////
      void printmatrix ( FILE *f, float **a,int kk)
        {
          for (int i=1;i<kk+1;i++)
            {
             for (int j=1;j<kk+2;j++)
               {
                   printf("%1.0f ",a[i][j]);
                  fprintf(f,"%1.0f ",a[i][j]);

               }
             printf("\n");
             fprintf(f,"\n");
            }
        }
int main()

  {
      int ttt,c,i,j,k,l,m,t,N,M;
      cout<<"N indica la particion de la grilla a lo largo del eje OX\n";
      cout<<"M indica la particion de la grilla a lo largo del eje OY\n";
      cout<<"\n";
      cout<<"N= ";
      cin>>N;
      float A=0.0; float B=1.0; float C=1.0;
      float h=(B-A)/(N-1);
      float tt=C/h;
      M=floor(tt)+1  ;
      cout<<"M= "<<M<<endl;
      int kk=(N-2)*(M-2);
      printf("h= %3.2f\n",h);
      double **a = new double* [kk+2];
      for(i = 0; i < kk+2; i++)
        a[i] = new double[kk+2];           
        if(!a){
                cerr << "Can't allocate space\n";
                return 1;
              }
      FILE *f;
      f=fopen("matrizascenso.txt","w+");
      for (i=1;i<kk+1;i++)
         for (j=1;j<kk+2;j++)
           a[i][j]=0.0;
      k=0;  t=1;
      for (i=1;i<kk+1;i++)
        {
            a[i][i]=-4.0;
            if (i>1)
              {
                ++k;
                 if (k!=M-2)
                       a[i][i-1]=a[i-1][i]=1;
                   else
                     {
                       a[i][i-1]=a[i-1][i]=0;
                       k=0;
                     }
              }
        } 
      k=1;
      for(i=M-1;i<kk+1;i++)
         {
           a[i][k]=a[k][i]=1.0;
           ++k;
         }
      for (i=2;i<M-2;i++)
         {
            a[i][kk+1]=-f3(i,h);
            a[i*(M-2)][kk+1]=-f2(i,h); 
            ttt=kk-(M-2)+i;
            a[ttt][kk+1]=-f4(i,h);
            ttt=(M-2)*(i-1)+1;
            a[ttt][kk+1]=-f1(i,h);
         }
      a[1][kk+1]=-(f1(1,h)+f3(1,h));
      a[M-2][kk+1]=-((f3(M-2,h)+f2(1,h)));
      a[kk-(M-2)+1][kk+1]=-(f1(M-2,h)+f4(1,h));
      a[kk][kk+1]=-(f2(M-2,h)+f4(M-2,h));
      for (i=1;i<kk+1;i++)
        {
          for (j=1;j<kk+2;j++)                  
           {
                 if ((j==kk+1)& (a[i][kk+1]!=0.0 ))
                  {
                     printf("%9.6f ",a[i][j]);
                     fprintf(f,"%9.6f ",a[i][j]);
                  }
                 else
                  {
                   printf("%1.0f ",a[i][j]);
                   fprintf(f,"%1.0f ",a[i][j]);
                  }
           }
          printf("\n");
          fprintf(f,"\n");
        }
      // fprintf(f,"h= %6.4f\n",h);
       fclose(f);
       getch();
       for (i=0; i<kk+2;i++)
          {
            delete[] a[i];

          }
        delete[] a;     

    }
/// end the program



 

Miguel Caro wrote:
> 
> Hello everybody,
> 
> Well, i am working with a Borland C++ version 4.0.
> 
> I am trying to write in a text file ("data.txt") a matrix with dimension
> 1089x1089 elements.
> 
> When i am going to check some elements of the matrix in this file then 
> appears a message  :
> 
> "One or more lines were too long and have been truncated"
> 
> and the last lines of the matrix in the file are  converting  in a
> "cocktail  of numbers"="puzzle".
> 
> What can i do to solve this problem?.
> 
> The elements of the matrix will be using in another file.
> 
> 
> Bye.
> 

-- 
View this message in context: 
http://www.nabble.com/Error-message-%3A%22One-or-more-lines-were-too-long-and-have-been-truncated%22-tp20389924p20389931.html
Sent from the C-prog mailing list archive at Nabble.com.

Reply via email to