//MODIFICAR ESTE METODO public static int[,] fillDinaMatriz(int pRow, int pCol) { int[,] matriz = null; int val = 0; bool checkVal = false; if ((pRow > 0) && (pRow < 10)) { if ((pCol > 0) && (pCol < 10)) { matriz = new int[pRow, pCol]; for (int i = 0; i < pRow; i++) { for (int j = 0; j < pCol; j++) { do { Console.WriteLine(); Console.WriteLine("Digite el valor de la fila {0} y de la columna {1}", i, j); checkVal = ToolBoxUtility.ValidateIntegerField(Console.ReadLine(), out val); if (checkVal) { matriz[i, j] = val; Program.ShowMatrizNums(matriz); Console.WriteLine(); } else { Console.WriteLine("El valor debe de ser de tipo entero"); } } while (!checkVal); } } } else { Console.WriteLine("El numero de columnas debe de ser positivo y menor a 10"); } } else { Console.WriteLine("El numero de filas debe de ser positivo y menor a 10"); } return(matriz); }
public static string Traslate(int num) { string printNum = string.Empty; contTraslation = true; numResid = num; if (ToolBoxUtility.ValidatePositiveNum(numResid)) { do { switch (numResid.ToString().Length) { case 1: printNum += numResid.GetUnitRoman(); break; case 2: printNum += numResid.GetTenRoman(); break; case 3: printNum += numResid.GetHundredRoman(); break; case 4: printNum += numResid.GetThousandRoman(); break; } } while (contTraslation); } else { throw new Exception("El numero debe de ser positivo"); } return(printNum); }
public static int[] FillArray(int pNumA1, int pNumA2, int ArrayLenght = 0, bool random = false, EnumResultNumber pFilterNumber = EnumResultNumber.All) { int[] mArray = null; int ramNumb = 0, i = 0; if (pNumA1 < pNumA2) { if (random) { if (ArrayLenght > 0) { Random ram = new Random(); mArray = new int[ArrayLenght]; while (i < mArray.Length) { ramNumb = ram.Next(pNumA1, pNumA2); if (ToolBoxUtility.OddNumbsFilter(ramNumb, pFilterNumber)) { mArray[i] = ramNumb; i++; } } } else { throw new Exception("Se necesita la longitud del array"); } } else { i = pNumA1; int cantElement = 0; while (i <= pNumA2) { if (ToolBoxUtility.OddNumbsFilter(i, pFilterNumber)) { cantElement++; } i++; } mArray = new int[cantElement]; i = 0; while (pNumA1 <= pNumA2) { if (ToolBoxUtility.OddNumbsFilter(pNumA1, pFilterNumber)) { mArray[i] = pNumA1; i++; } pNumA1++; } } } else if (pNumA1 > pNumA2) { mArray = new int[pNumA1]; i = 0; while (pNumA1 > pNumA2) { if (ToolBoxUtility.OddNumbsFilter(pNumA1, pFilterNumber)) { mArray[i] = pNumA1; pNumA1 -= 1; i++; } } } return(mArray); }