当前位置: 首页>>代码示例>>C#>>正文


C# BigInteger.GetLength方法代码示例

本文整理汇总了C#中BigInteger.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.GetLength方法的具体用法?C# BigInteger.GetLength怎么用?C# BigInteger.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigInteger的用法示例。


在下文中一共展示了BigInteger.GetLength方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    static void Main()
    {
        int rows = int.Parse(Console.ReadLine());
        int cols = int.Parse(Console.ReadLine());
        long verticallyStart = long.Parse(Console.ReadLine());
        long horizontallyStart = long.Parse(Console.ReadLine());

        BigInteger n = verticallyStart * horizontallyStart;
        BigInteger tempStart = n;

        BigInteger[,] matrix = new BigInteger[rows, cols];

        for (int i = 0; i < matrix.GetLength(0); i++)
        {
            for (int j = 0; j < matrix.GetLength(1); j++)
            {
                matrix[i, j] = tempStart;
                tempStart += verticallyStart;
            }
            n += horizontallyStart;
            tempStart = n;
            verticallyStart++;

        }

        for (int i = 0; i < matrix.GetLength(0); i++)
        {
            for (int j = 0; j < matrix.GetLength(1); j++)
            {
                Console.Write("{0} ", matrix[i, j]);
            }
            Console.WriteLine();
        }
    }
开发者ID:vanncho,项目名称:SoftUni-Entrance-Exam-Prepare,代码行数:34,代码来源:CheatSheet.cs

示例2: Main

 static void Main()
 {
     string input = Console.ReadLine();
     BigInteger[,] combCount = new BigInteger[input.Length / 2 + 1, input.Length]; //combinations count with number open brackets
     combCount[1, 0] = 1;
     for (int c = 1; c < combCount.GetLength(1); c++)
     {
         for (int r = 0; r < combCount.GetLength(0); r++)
         {
             if (combCount[r, c - 1] > 0)
             {
                 if (input[c] == '(' && r + 1 < combCount.GetLength(0))
                 {
                     combCount[r + 1, c] += combCount[r, c - 1];
                 }
                 else if (input[c] == ')' && r - 1 >= 0)
                 {
                     combCount[r - 1, c] += combCount[r, c - 1];
                 }
                 else if(input[c] == '?' && r + 1 < combCount.GetLength(0))
                 {
                     combCount[r + 1, c] += combCount[r, c - 1]; ;
                 }
                 if (input[c] == '?' && r - 1 >= 0)
                 {
                     combCount[r - 1, c] += combCount[r, c - 1]; ;
                 }
             }
         }
     }
     Console.WriteLine(combCount[0, combCount.GetLength(1) - 1]);
 }
开发者ID:kalinalazarova1,项目名称:TelerikAcademy,代码行数:32,代码来源:Brackets.cs

示例3: CreateMatrix

    private static BigInteger[,] CreateMatrix(int Rows, int Cols)
    {
        BigInteger[,] matrix = new BigInteger[Rows, Cols];

        for (int row = matrix.GetLength(0) - 1; row >= 0; row--)
        {
            for (int col = 0; col < matrix.GetLength(1); col++)
            {
                int rowPower = matrix.GetLength(0) - row - 1;
                int colPower = col;

                if (row == Rows - 1 && col == 0)
                {
                    matrix[row, col] = 1;
                }
                else if (row == Rows - 1)
                {
                    matrix[row, col] = (BigInteger)Math.Pow(2, colPower);
                }
                else if (col == 0)
                {
                    matrix[row, col] = (BigInteger)Math.Pow(2, rowPower);
                }
                else
                {
                    matrix[row, col] = matrix[row, col - 1] + matrix[row + 1, col];
                }
            }
        }
        return matrix;
    }
开发者ID:matioa,项目名称:TelerikAcademyHomeworks,代码行数:31,代码来源:LoveOf2.cs

示例4: printMatrix

 static void printMatrix(BigInteger[,] matrix)
 {
     for (int i = 0; i < matrix.GetLength(0); i++)
     {
         for (int j = 0; j < matrix.GetLength(1); j++)
         {
             Console.Write("{0, 5} ", matrix[i, j]);
         }
         Console.WriteLine();
     }
 }
开发者ID:AyrFX,项目名称:Telerik-Academy-2015-HQC-Homeworks,代码行数:11,代码来源:BitShiftMatrixDemo.cs

示例5: CalcualateSum

    static BigInteger CalcualateSum(BigInteger[,] matrix, int moves, int[] codes)
    {
        int rows = matrix.GetLength(0);
        int cols = matrix.GetLength(1);
        int devider = Math.Max(rows, cols);
        BigInteger sum = 0;

        int currentRow = rows - 1;
        int currentCol = 0;
        for (int i = 0; i < codes.Length; i++)
        {
            int row = codes[i] / devider;
            int col = codes[i] % devider;

            if (currentRow > row)
            {
                for (int r = currentRow; r >= row; r--)
                {
                    sum += matrix[r, currentCol];
                    matrix[r, currentCol] = 0;
                }
                currentRow = row;
            }
            else
            {
                for (int r = currentRow; r <= row; r++)
                {
                    sum += matrix[r, currentCol];
                    matrix[r, currentCol] = 0;
                }
                currentRow = row;
            }
            if (currentCol > col)
            {
                for (int c = currentCol; c >= col; c--)
                {
                    sum += matrix[currentRow, c];
                    matrix[currentRow, c] = 0;
                }
                currentCol = col;
            }
            else
            {
                for (int c = currentCol; c <= col; c++)
                {
                    sum += matrix[currentRow, c];
                    matrix[currentRow, c] = 0;
                }
                currentCol = col;
            }
        }
        return sum;
    }
开发者ID:glifada,项目名称:TelerikAcademy,代码行数:53,代码来源:LoverOf3.cs

示例6: CalculateSum

    private static BigInteger CalculateSum(bool[,] visitedCells, BigInteger[,] matrix)
    {
        BigInteger sum = 0;
        for (int row = 0; row < matrix.GetLength(0); row++)
        {
            for (int col = 0; col < matrix.GetLength(1); col++)
            {
                if (visitedCells[row, col])
                {
                    sum += matrix[row, col];
                }
            }
        }

        return sum;
    }
开发者ID:monikaBchvarova,项目名称:C-Sharp,代码行数:16,代码来源:Program.cs

示例7: GetFilledMatrix

    internal static BigInteger[,] GetFilledMatrix(byte matrixRows, byte matrixCols)
    {
        BigInteger[,] matrix = new BigInteger[matrixRows, matrixCols];
        for (int row = matrix.GetLength(0) - 1; row >= 0; row--)
        {
            for (int col = 0; col < matrix.GetLength(1); col++)
            {
                matrix[row, col] = (BigInteger)Math.Pow(2, col + matrix.GetLength(0) - row - 1);
            }
        }

        return matrix;
    }
开发者ID:AyrFX,项目名称:Telerik-Academy-2015-HQC-Homeworks,代码行数:13,代码来源:BitShiftMatrixDemo.cs

示例8: CountWays

    private static BigInteger CountWays(BigInteger[,] field)
    {
        for (int row = 0; row < field.GetLength(0); row++)
        {
            for (int col = 0; col < field.GetLength(1); col++)
            {
                if (row == 0 && col == 0)
                {
                    field[0, 0] = 1;
                    continue;
                }

                if (field[row, col] == -1)
                {
                    field[row, col] = 0;
                    continue;
                }

                if (row == 0)
                {
                    field[0, col] = field[0, col - 1];
                    continue;
                }

                if (col == 0)
                {
                    field[row, 0] = field[row - 1, 0];
                    continue;
                }

                field[row, col] = field[row - 1, col] + field[row, col - 1];
            }
        }

        return field[finalRow, finalCol];
    }
开发者ID:jerko0,项目名称:Telerik-Academy,代码行数:36,代码来源:HelpDoge.cs

示例9: Main

    static void Main()
    {
        string input = Console.ReadLine();

            BigInteger[][] table = new BigInteger[input.Length + 2][];
            table[1] = new BigInteger[input.Length + 1];
            table[1][1] = 1;

            for (int row = 2; row < table.GetLength(0); row++)
            {
                table[row] = new BigInteger[input.Length + 1];
                for (int col = 1; col < table[row].Length; col++)
                {
                    if (row < table.Length  && col < table[row].Length  - 1)
                    {
                        if (input[row - 2] == '?')
                        {
                            table[row][col] = table[row - 1][col - 1] + table[row - 1][col + 1];

                        }
                        if (input[row - 2] == '(')
                        {
                            table[row][col] = table[row - 1] [col - 1];
                        }
                        if (input[row - 2] == ')')
                        {
                            table[row][ col] = table[row - 1][col + 1];
                        }

                    }
                }
                table[row - 1] = null;
            }
            //Print(table);
            Console.WriteLine(table[table.Length - 1][ 1]);
    }
开发者ID:Wooanna,项目名称:GitHubTelerikAcademy,代码行数:36,代码来源:Program.cs

示例10: Main

 static void Main()
 {
     int matrixRows = int.Parse(Console.ReadLine());
     int matrixCols = int.Parse(Console.ReadLine());
     //======================
     int movesNumber = int.Parse(Console.ReadLine());
     string[] codes = Console.ReadLine().Split(' ');
     int[,] points = new int[movesNumber+1, 2];
     points[0, 0] = matrixRows - 1;
     points[0, 1] = 0;
     for (int i = 0; i < codes.Length; i++)
     {
         points[i + 1, 0] = int.Parse(codes[i]) / Math.Max(matrixRows, matrixCols);
         points[i + 1, 1] = int.Parse(codes[i]) % Math.Max(matrixRows, matrixCols);
     }
     //=======================
     BigInteger [,] matrix = new BigInteger[matrixRows, matrixCols];
     for (int i = matrix.GetLength(0) - 1; i >= 0; i--)
     {
         for (int j = 0; j < matrix.GetLength(1); j++)
         {
             matrix[i, j] = (BigInteger)Math.Pow(2, j + matrix.GetLength(0) - i - 1);
         }
     }
     //========================
     int fromRow, fromCol, toRow, toCol;
     BigInteger collectedPoints = 0;
     for (int i = 0; i < points.GetLength(0) - 1; i++)
     {
         fromRow = points[i, 0];
         fromCol = points[i, 1];
         toRow = points[i + 1, 0];
         toCol = points[i + 1, 1];
         if (fromCol < toCol)
         {
             for (int j = fromCol; j <= toCol; j++)
             {
                 collectedPoints += matrix[fromRow, j];
                 matrix[fromRow, j] = 0;
                 //Console.WriteLine("row={0}, col={1}", fromRow, j);
             }
         }
         else
             for (int j = fromCol; j >= toCol; j--)
             {
                 collectedPoints += matrix[fromRow, j];
                 matrix[fromRow, j] = 0;
                 //Console.WriteLine("row={0}, col={1}", fromRow, j);
             }
         if (fromRow < toRow)
         {
             for (int j = fromRow; j <= toRow; j++)
             {
                 collectedPoints += matrix[j, toCol];
                 matrix[j, toCol] = 0;
                 //Console.WriteLine("row={0}, col={1}", j, toCol);
             }
         }
         else
         {
             for (int j = fromRow; j >= toRow; j--)
             {
                 collectedPoints += matrix[j, toCol];
                 matrix[j, toCol] = 0;
                 //Console.WriteLine("row={0}, col={1}", j, toCol);
             }
         }
         //printMatrix(matrix);
         //Console.WriteLine("Result after point {0} = {1}", i + 1, collectedPoints);
     }
     Console.WriteLine("{0:D2}", collectedPoints);
 }
开发者ID:AyrFX,项目名称:Telerik-Academy-2015-HQC-Homeworks,代码行数:72,代码来源:BitShiftMatrixDemo.cs

示例11: PrintMatrix

 private static void PrintMatrix(BigInteger[,] matrix)
 {
     for (int row = 0; row < matrix.GetLength(0); row++)
     {
         for (int col = 0; col < matrix.GetLength(1); col++)
         {
             Console.Write("{0}".PadRight(5), matrix[row, col]);
         }
         Console.WriteLine();
     }
 }
开发者ID:monikaBchvarova,项目名称:C-Sharp,代码行数:11,代码来源:Program.cs


注:本文中的BigInteger.GetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。