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,150

    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.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured