0

本で次のコードを見つけました。正直なところ、本で見つけたものを説明してコメントする方法がわかりません。

private int GreatestIncrease(List<int> PopulationList)                              //Imports the population list to Greatest.

{
    int amountOfChange = 0;
    int changeInYears = 0;
    int i;
    int theChange = 0;
    int currentYear = 0;

    for (i = 1; i < PopulationList.Count(); i++)
    {
        theChange = PopulationList[i] - PopulationList[i - 1];
        currentYear = i;

        if (theChange > amountOfChange)
        {
            amountOfChange = theChange;
            changeInYears = i;
        }
    }

    return changeInYears;
}

private int LeastIncrease(List<int> PopulationList)                                 //Imports the population list to Least.
{
    int firstItem = PopulationList.First();
    int lastItem = PopulationList.Last();

    int amountOfChange = (lastItem - firstItem);
    int changeInYears = 0;
    int i;
    int theChange = 0;
    int CurrentYear = 0;

    for (i = 1; i < PopulationList.Count(); i++)
    {
        theChange = PopulationList[i] - PopulationList[i - 1];
        CurrentYear = i;

        if (theChange < amountOfChange)
        {
            amountOfChange = theChange;
            changeInYears = i;
        }
    }

    return changeInYears;
}
4

3 に答える 3