1. Список говнокодов пользователя mr07th

    Всего: 1

  2. C# / Говнокод #16001

    +123

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    namespace Рунге_Кутты_1._4
    {
        public partial class Form1 : Form
        {
            double x0 = 1, y0 = 2, z0 = 4, t0 = 0, T = 1, h = 0.001, Eps = 0.000001, fx, fy, fz, xx, yy, zz, Ex, Ey, Ez, Eps1;
            double[] x = new double[4]; double[] y = new double[4]; double[] z = new double[4];
            double[] Kx = new double[4]; double[] Ky = new double[4]; double[] Kz = new double[4];
            bool a;
            public void Calculates()
            {
                System.IO.File.Delete(@"C:\Results\results.dat");
                x[0] = x0; y[0] = y0; z[0] = z0;
                while (t0 <= T)
                {
                    for (int i = 0; i <= 3; i++)
                    {
                        fx = -y[i] - z[i];
                        fy = x[i] + 0.2 * y[i];
                        fz = 0.2 + (x[i] - 5.7) * z[i];
                        Kx[i] = h * fx;
                        Ky[i] = h * fy;
                        Kz[i] = h * fz;
                        x[1] = x[0] + 0.5 * Kx[0];
                        x[2] = x[0] + 0.5 * Kx[1];
                        x[3] = x[0] + Kx[2];
                        y[1] = y[0] + 0.5 * Ky[0];
                        y[2] = y[0] + 0.5 * Ky[1];
                        y[3] = y[0] + Ky[2];
                        z[1] = z[0] + 0.5 * Kz[0];
                        z[2] = z[0] + 0.5 * Kz[1];
                        z[3] = z[0] + Kz[2];
                    }
                    Ex = Math.Abs(2 * (Kx[0] - Kx[1] - Kx[2] + Kx[3]) / 3);
                    Ey = Math.Abs(2 * (Ky[0] - Ky[1] - Ky[2] + Ky[3]) / 3);
                    Ez = Math.Abs(2 * (Kz[0] - Kz[1] - Kz[2] + Kz[3]) / 3);
                    Eps1 = Eps / 8;
                    a = Check();
                    if (a == false)
                    {
                        xx = x[0] + (Kx[0] + 2 * Kx[1] + 2 * Kx[2] + Kx[3]) / 6;
                        yy = y[0] + (Ky[0] + 2 * Ky[1] + 2 * Ky[2] + Ky[3]) / 6;
                        zz = z[0] + (Kz[0] + 2 * Kz[1] + 2 * Kz[2] + Kz[3]) / 6;
                        x[0] = xx;
                        y[0] = yy;
                        z[0] = zz;
                        t0 += h;
                        string f1 = Convert.ToString(xx);
                        string f2 = Convert.ToString(yy);
                        string f3 = Convert.ToString(zz);
                        string[] f = new string[] { f1, f2, f3 };
                        string path = @"C:\Results\results.dat";
                        string appendtext = xx + " " + yy + " " + zz + Environment.NewLine;
                        System.IO.File.AppendAllText(path, appendtext);
                    }
                }
            }
            public bool Check()
            {
                bool a;
                if (Ex > Eps | Ey > Eps | Ez > Eps)
                {
                    a = true;
                    h /= 2;
                    Calculates();
                }
                else a = false;
                return a;
            }
            public Form1()
            {
                InitializeComponent();
                Calculates();
                DrawGraph();
            }
            public void DrawGraph()
            {
                    GraphPane pane = zedGraph.GraphPane;
                    pane.CurveList.Clear();
                    PointPairList list = new PointPairList();
                    for (t0 = 0; t0 <= T; t0 += h)
                    {
                        list.Add(t0, x[0]);
                    }
                    LineItem MyCurve = pane.AddCurve("x(t)", list, Color.Blue, SymbolType.None);
                    zedGraph.AxisChange();
                    zedGraph.Invalidate();
            }
        }
    }

    пытаюсь вывести решения в виде графика. выводится только последнее решение из цикла

    mr07th, 16 Мая 2014

    Комментарии (7)