matrix
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: matrix

  1. #1
    Join Date
    Oct 2011
    Posts
    1

    matrix

    Hi, I'm newbie in C++. I found a code in assemblylineScduling using dynamic programming.

    In part of the codes, I found,

    Code:
    for(i=0; i<numStations; i++)  //numStation=5
    		{
    			for(j=0; j < numLines; j++)  //numLines 2
    			{
    				for(k=0; k < numLines; k++)
    				{
    					
    					if(j!=k && i!=numStations-1 )
    					{ 
    						fin >> transferCost[j][i][k]; 				
    					}
    					else
    					{ 
    						transferCost[j][i][k]=0; 
    					}
    				}
    			}
    		}
    where,
    fin, I believe is the .dat input file with the transfer costs as follows,

    2 2
    3 1
    1 2
    3 2
    4 1

    I wonder what is this, fin >> transferCost[j][i][k]; means.

    If I'm not wrong, mat[2][3] is: 1 1 1
    1 1 1

    what will be transferCost[][][] outputs in the above statement? and how about
    transferCost[j][i][k]=0;

    thanks in advance!
    Last edited by Marc G; October 20th, 2011 at 02:28 AM. Reason: Added code tags

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    Re: matrix

    fin >> transferCost[j][i][k];
    Read a value from the fin stream into the 3D array transferCost at position j,i,k.
    So, if transferCost contains integers, that lines will read 1 integer and store it in the array at position j,i,k.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center