Загрузка данных
Программ
using System;
using System.Windows.Forms;
namespace Variant14
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Форм
using System;
using System.Windows.Forms;
namespace Variant14
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
double p = double.Parse(textBoxP.Text);
double b = double.Parse(textBoxB.Text);
double c = double.Parse(textBoxC.Text);
int N = int.Parse(textBoxN.Text);
int R = int.Parse(textBoxR.Text);
// --- Часть 1 (ряд) ---
double Z1 = 0;
int factorial = 1;
for (int k = 2; k <= 5; k++)
{
factorial *= k;
double term = Math.Pow(p, k) / factorial;
if (k % 2 == 0)
Z1 -= term;
else
Z1 += term;
}
// --- Часть 2 (двойная сумма) ---
double Z2 = 0;
for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= R; j++)
{
double numerator = Math.Pow(i, 2) + b * j;
double denominator = Math.Pow(c, i) * Math.Pow(j, 3);
Z2 += numerator / denominator;
}
}
double Z = Z1 + Z2;
labelResult.Text = "Z = " + Z.ToString("F5");
}
catch
{
MessageBox.Show("Ошибка ввода данных!");
}
}
}
}
Дизайнер
namespace Variant14
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.TextBox textBoxP;
private System.Windows.Forms.TextBox textBoxB;
private System.Windows.Forms.TextBox textBoxC;
private System.Windows.Forms.TextBox textBoxN;
private System.Windows.Forms.TextBox textBoxR;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label labelResult;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.textBoxP = new System.Windows.Forms.TextBox();
this.textBoxB = new System.Windows.Forms.TextBox();
this.textBoxC = new System.Windows.Forms.TextBox();
this.textBoxN = new System.Windows.Forms.TextBox();
this.textBoxR = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.labelResult = new System.Windows.Forms.Label();
this.SuspendLayout();
// textBoxP
this.textBoxP.Location = new System.Drawing.Point(30, 30);
this.textBoxP.PlaceholderText = "p";
// textBoxB
this.textBoxB.Location = new System.Drawing.Point(30, 70);
this.textBoxB.PlaceholderText = "b";
// textBoxC
this.textBoxC.Location = new System.Drawing.Point(30, 110);
this.textBoxC.PlaceholderText = "c";
// textBoxN
this.textBoxN.Location = new System.Drawing.Point(30, 150);
this.textBoxN.PlaceholderText = "N";
// textBoxR
this.textBoxR.Location = new System.Drawing.Point(30, 190);
this.textBoxR.PlaceholderText = "R";
// button1
this.button1.Location = new System.Drawing.Point(30, 230);
this.button1.Text = "Вычислить";
this.button1.Click += new System.EventHandler(this.button1_Click);
// labelResult
this.labelResult.Location = new System.Drawing.Point(30, 270);
this.labelResult.Size = new System.Drawing.Size(200, 30);
this.labelResult.Text = "Z = ";
// Form1
this.ClientSize = new System.Drawing.Size(300, 350);
this.Controls.Add(this.textBoxP);
this.Controls.Add(this.textBoxB);
this.Controls.Add(this.textBoxC);
this.Controls.Add(this.textBoxN);
this.Controls.Add(this.textBoxR);
this.Controls.Add(this.button1);
this.Controls.Add(this.labelResult);
this.Text = "Вариант 14";
this.ResumeLayout(false);
this.PerformLayout();
}
}
}