some sec fixes
This commit is contained in:
@@ -35,7 +35,7 @@ namespace Lab
|
||||
long a = 1;
|
||||
long b = 1;
|
||||
List<long> list = new List<long>();
|
||||
while (a < n) { list.Add(a); long next = a + b; a = b; b = next; }
|
||||
while (a < n) { list.Add(a); if (long.MaxValue - a < b) break; long next = a + b; a = b; b = next; }
|
||||
|
||||
OutBox.Text = string.Join(", ", list);
|
||||
InfoText.Text = $"Найдено чисел: {list.Count}.";
|
||||
|
||||
@@ -79,7 +79,9 @@ namespace Lab
|
||||
{
|
||||
for (int col = 0; col < cols; col++)
|
||||
{
|
||||
array[row, col] = Convert.ToInt32(dt.Rows[row][col]);
|
||||
double num = (double)dt.Rows[row][col];
|
||||
num = double.IsInfinity(num) || double.IsNaN(num) ? 0 : num;
|
||||
array[row, col] = Convert.ToInt32(num);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,12 @@ namespace Lab
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rows > 50 || cols > 50)
|
||||
{
|
||||
FlipInfoText.Text = "Возможно, но превосходит вычислительные мощности.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,13 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Lab
|
||||
{
|
||||
internal class Parsers
|
||||
{
|
||||
public static bool TryParseDouble(string? s, out double val) => double.TryParse((s ?? "").Trim().Replace(",", "."), out val);
|
||||
public static bool TryParseDouble(string? s, out double val) => double.TryParse((s ?? "").Trim().Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture, out val) && !double.IsNaN(val) && !double.IsInfinity(val);
|
||||
public static bool TryParseInt(string? s, out int val) => int.TryParse((s ?? "").Trim(), out val);
|
||||
|
||||
public static bool TryParseDoubleArray(string? s, out double[] vals, out string err)
|
||||
@@ -21,7 +22,7 @@ namespace Lab
|
||||
return false;
|
||||
}
|
||||
|
||||
string[] parts = s.Split(new[] { ' ', '\t', '\n', '\r', ',', ';' });
|
||||
string[] parts = s.Split(new[] { ' ', '\t', '\n', '\r', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
List<double> list = new List<double>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user