использование разных операторов в скобках

This commit is contained in:
a 2025-12-08 15:00:07 +04:00
parent ddd7a300b0
commit 1f54cd33f7
19 changed files with 61 additions and 22 deletions

Binary file not shown.

View File

@ -2,5 +2,6 @@
"ExpandedNodes": [
""
],
"SelectedNode": "\\Calculator.sln",
"PreviewInSolutionExplorer": false
}

BIN
.vs/calc_version4/v17/.wsuo Normal file

Binary file not shown.

26
Form1.Designer.cs generated
View File

@ -236,19 +236,19 @@
//
// textBox1
//
this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.textBox1.Location = new System.Drawing.Point(71, 79);
this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.textBox1.Location = new System.Drawing.Point(26, 110);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(338, 80);
this.textBox1.Size = new System.Drawing.Size(397, 40);
this.textBox1.TabIndex = 15;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged_1);
//
// textBox2
//
this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.textBox2.Location = new System.Drawing.Point(559, 78);
this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.textBox2.Location = new System.Drawing.Point(529, 106);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(781, 80);
this.textBox2.Size = new System.Drawing.Size(781, 44);
this.textBox2.TabIndex = 16;
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
@ -256,18 +256,19 @@
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label2.Location = new System.Drawing.Point(64, 25);
this.label2.Location = new System.Drawing.Point(64, 37);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(221, 42);
this.label2.TabIndex = 17;
this.label2.Text = "Выражения";
this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.label2.Click += new System.EventHandler(this.label2_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label3.Location = new System.Drawing.Point(550, 25);
this.label3.Location = new System.Drawing.Point(550, 37);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(197, 42);
this.label3.TabIndex = 18;
@ -305,9 +306,10 @@
this.button17.BackColor = System.Drawing.Color.LightPink;
this.button17.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button17.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.button17.Location = new System.Drawing.Point(429, 85);
this.button17.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.button17.Location = new System.Drawing.Point(429, 92);
this.button17.Name = "button17";
this.button17.Size = new System.Drawing.Size(94, 89);
this.button17.Size = new System.Drawing.Size(94, 74);
this.button17.TabIndex = 21;
this.button17.Text = "=";
this.button17.UseVisualStyleBackColor = false;
@ -448,7 +450,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.ClientSize = new System.Drawing.Size(1352, 665);
this.ClientSize = new System.Drawing.Size(1283, 657);
this.Controls.Add(this.button27);
this.Controls.Add(this.button18);
this.Controls.Add(this.button26);
@ -482,7 +484,7 @@
this.Controls.Add(this.button1);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.Name = "Form1";
this.Text = "Form1";
this.Text = "THE CALCULATR 3000";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -139,23 +139,26 @@ namespace Calculator
Analaizer.expression = expression;
if (!Analaizer.CheckCurrency())
{
textBox2.Text = "Некорректные скобки";
return;
}
expression = expression.Replace(" " , "");
expression = expression.Replace("(", "");
expression = expression.Replace(")", "");
if (expression.StartsWith("sin(",StringComparison.OrdinalIgnoreCase) &&
expression = expression.Replace(" ", "");
if (expression.StartsWith("sin(", StringComparison.OrdinalIgnoreCase) &&
expression.EndsWith(")"))
{
string innerExpression = expression.Substring(4,expression.Length - 5);
if (double.TryParse(innerExpression,out double angle))
string innerExpression = expression.Substring(4, expression.Length - 5);
if (double.TryParse(innerExpression, out double angle))
{
double result = CalcClass.Sinus(angle);
textBox2.Text = result.ToString("F6");
return;
}
@ -182,7 +185,28 @@ namespace Calculator
}
}
if (expression.Contains('+'))
else if (expression.Contains('(') || expression.Contains(')'))
{
Analaizer.expression = expression;
string result = Analaizer.Estimate();
if (result.StartsWith("Error"))
{
textBox2.Text = "ошибка";
}
else
{
textBox2.Text = result;
}
return;
}
else if (expression.Contains('+'))
{
string[] parts = expression.Split('+');
if (parts.Length >= 2)

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
dfad68e59b1a7b1521ac767c0c2131b1854d75890d1965b341aa3a4a598c0466
d004777b21b377d6d22bd1594218e7558a685dbb9550b72628da5d93ea66b998

View File

@ -23,3 +23,15 @@ C:\Users\Student\Desktop\pOSHVA\obj\Debug\Calculator.csproj.CoreCompileInputs.ca
C:\Users\Student\Desktop\pOSHVA\obj\Debug\Calculator.csproj.CopyComplete
C:\Users\Student\Desktop\pOSHVA\obj\Debug\Calculator.exe
C:\Users\Student\Desktop\pOSHVA\obj\Debug\Calculator.pdb
C:\Users\Student\Source\Repos\calc_version4\bin\Debug\Calculator.exe.config
C:\Users\Student\Source\Repos\calc_version4\bin\Debug\Calculator.exe
C:\Users\Student\Source\Repos\calc_version4\bin\Debug\Calculator.pdb
C:\Users\Student\Source\Repos\calc_version4\bin\Debug\CalcClass.dll
C:\Users\Student\Source\Repos\calc_version4\obj\Debug\Calculator.csproj.AssemblyReference.cache
C:\Users\Student\Source\Repos\calc_version4\obj\Debug\Calculator.Form1.resources
C:\Users\Student\Source\Repos\calc_version4\obj\Debug\Calculator.Properties.Resources.resources
C:\Users\Student\Source\Repos\calc_version4\obj\Debug\Calculator.csproj.GenerateResource.cache
C:\Users\Student\Source\Repos\calc_version4\obj\Debug\Calculator.csproj.CoreCompileInputs.cache
C:\Users\Student\Source\Repos\calc_version4\obj\Debug\Calculator.csproj.CopyComplete
C:\Users\Student\Source\Repos\calc_version4\obj\Debug\Calculator.exe
C:\Users\Student\Source\Repos\calc_version4\obj\Debug\Calculator.pdb

Binary file not shown.

Binary file not shown.