Составить блок-схему по готовой программе - C#
Формулировка задачи:
Помогите пожалуйста составить блок-схему) ума не приложу как это сделать
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
namespace hpseo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//Opacity = 0;
//Timer timer = new Timer();
//timer.Tick += new EventHandler((sender, e) =>
//{
// if ((Opacity += 0.25d) == 1) timer.Stop();
//});
//timer.Interval = 100;
//timer.Start();
//изменение прозрачности формы при загрузке. Создаёт эффект плавного появления, но на слабых машинах может вызвать подвисания.
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://wordstat.yandex.ru"); webBrowser2.Navigate("https://adwords.google.com/o/KeywordTool");
//при загрузке формы загружаются в веббраузеры с прописанными адресами.
ToolTip t = new ToolTip();
t.SetToolTip(pictureBox1, "Выход");
ToolTip r = new ToolTip();
r.SetToolTip(pictureBox2, "Развернуть");
ToolTip y = new ToolTip();
y.SetToolTip(pictureBox3, "Сохранить");
ToolTip f = new ToolTip();
f.SetToolTip(pictureBox4, "Свернуть");
//загружаются подсказки
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.Close();
//«кнопка закрыть»
}
private void pictureBox2_Click(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Maximized)
this.WindowState = FormWindowState.Normal;
else this.WindowState = FormWindowState.Maximized;
// «кнопка развернуть и вернуть форму в прежнее состояние»
}
private void pictureBox3_Click(object sender, EventArgs e)
{
System.IO.File.WriteAllText(@"\Frequency Helper\sys\x.txt", webBrowser1.Document.Body.Parent.OuterText, Encoding.GetEncoding(webBrowser1.Document.Encoding));
//сохраняет в документ всё содержимое страницы
System.IO.File.WriteAllText(@"\Frequency Helper\sys\x2.txt", File.ReadAllText(@"\Frequency Helper\sys\x.txt").Replace(File.ReadAllText(@"\Frequency Helper\sys\1.txt"), ""));
//из документа x.txt удаляется содержимое 1.txt и сохраняет в x2.txt
System.IO.File.WriteAllText(@"\Frequency Helper\yandex_keyword.txt", File.ReadAllText(@"\Frequency Helper\sys\x2.txt").Replace(File.ReadAllText(@"\Frequency Helper\sys\2.txt"), ""));
//из x2.txt удаляет содержимое 2.txt. и сохраняет в конечный файл yandex_keyword.txt
}
private void pictureBox4_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
//позволяет свенуть форму
}
private void pictureBox5_Click(object sender, EventArgs e)
{
Form3 f = new Form3();
f.Show();
//вызывает 3форму с информацией о программе
}
}
}Решение задачи: «Составить блок-схему по готовой программе»
textual
Листинг программы
using System;
using System.Collections.Generic;
namespace Model
{
public enum OptimizationDirection
{
ToMin,ToMax
}
public class Rosenbrock
{
private readonly Func<double[], double> f;
private readonly double epsilon;
private Vector y;
private Vector[] d;
private readonly int n;
private readonly List<IterationDetails> details = new List<IterationDetails>();
public OptimizationDirection Direction = OptimizationDirection.ToMin;
public IEnumerable<IterationDetails> Details { get { return new List<IterationDetails>(details); } }
public Rosenbrock(Func<double[], double> f, Vector startPoint, double epsilon)
{
if (startPoint.IsEmpty)
throw new ArgumentException("startPoint");
n = startPoint.Length;
this.f = x => Direction == OptimizationDirection.ToMin ? f(x) : -f(x);
this.epsilon = epsilon;
y = startPoint;
d = new Vector[n];
for (int i = 0; i < n; i++)
{
d[i] = new Vector(n);
d[i][i] = 1;
}
SmartPoint.SetFunction(f);
}
public Vector Solve()
{
int k = 0;
details.Clear();
var lambda = new Vector(n);
Vector previousIterationY;
do
{
k++;
previousIterationY = y;
var iterDetails = new IterationDetails(y, k);
for (int j = 0; j < n; j++)
{
var previousStepY = y;
int i = j;
lambda[j] = Dichotomy(x => LambdaSolve(x, i), y[j]);
y += lambda[j] * d[j];
iterDetails.Add(new StepDetails(previousStepY, lambda[j], d[j], y, i+1));
}
details.Add(iterDetails);
d = GramSchmidtProcess(lambda);
} while ((y - previousIterationY).Norm >= epsilon);
return y;
}
private double LambdaSolve(double x, int j)
{
return f(y + x * d[j]);
}
private Vector[] GramSchmidtProcess(Vector lambda)
{
var a = new Vector[n];
for (int j = 0; j < n; j++)
if (Math.Abs(lambda[j]) < epsilon) //Если ноль
a[j] = d[j];
else
{
a[j] = new Vector(n);
for (int i = j; i < n; i++)
a[j] += lambda[i] * d[i];
}
var b = (Vector[])a.Clone();
b[0].Normalize();
for (int j = 1; j < n; j++)
{
for (int i = 0; i < j; i++)
b[j] -= Vector.TransposeAndMultiply(a[j], b[i]) * b[i];
b[j].Normalize();
}
return b;
}
private double Dichotomy(Func<double, double> func, double startCoord)
{
double deviation = Math.Abs(startCoord) < double.Epsilon ? 5 : Math.Abs(startCoord) * 0.5 + 10;
double a = startCoord - deviation, b = startCoord + deviation;
double delta = epsilon / 10;
while (b - a >= epsilon)
{
double middle = (a + b) / 2;
double lambda = middle - delta, mu = middle + delta;
if (func(lambda) < func(mu))
b = mu;
else
a = lambda;
}
return (a + b) / 2;
}
}
}