Skip to content

Instantly share code, notes, and snippets.

Created September 13, 2017 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0acff046507a8c03e97bbf8229693d99 to your computer and use it in GitHub Desktop.
Save anonymous/0acff046507a8c03e97bbf8229693d99 to your computer and use it in GitHub Desktop.
ass01_softcomp
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace r05546043HongyiAss01
{
public partial class Form1 : Form
{
private readonly object txbGSigma;
public Form1()
{
InitializeComponent();
}
//不小心寫錯
private void button1_MouseCaptureChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
//BTN 快押兩次
double c, sigma;
//c = txbGextbox.Text
//.net framework 類別轉換
c = Convert.ToDouble(textBox1.Text); // string convert to double involve
sigma = Convert.ToDouble(textBox2.Text);
chart1.Series[0].Points.Clear(); // 清除原始 Diagram before 進入 Loop
//<!------CHART-------------->
for (double x = -10; x <= 10; x = x + 0.1)
{
double y;
y = Math.Exp(-(x - c) * (x - c) / sigma / sigma);
chart1.Series[0].Points.AddXY(x, y);
}
//<!-----------第a小題-------------------->
//Array[i,j,k]
double i;
i = Convert.ToDouble(textBox1.Text);
for (double z = -10; z <= 10; z = z + 0.1)
{
double a;
double b;
double c1;
a = 0;
b = 0;
c1 = 0;
if (z <= a)
{
z = 0;
}
else if (a <= z && z <= b)
{
z = (z - a) / (b - a);
}
else if (b <= i && i <= c1)
{
i = (c1 - z) / (c1 - b);
}
else if (z >= c1)
{
z = 0;
}
else
{ }
}
// for (double i = -10; i <= 10; i = i + 0.1)
// {
// //double j, k, l;
// //j = 0;
// //k = 0;
// //l = 0;
// switch (i,j,k)
// {
// case 1:
// Console.WriteLine();
// break;
// case 2:
// Console.WriteLine();
// break;
// default:
// break;
// }
// }
//}
//<!------------------c小題------------------->
for (double z2 = -10; z2<= 10; z2 = z2 + 0.1) //修改變數名稱
{
double a3,c3,b3, Ans;
a3 = b3 = c3 = 0;
Ans =1 / (1 + Math.Pow( (Math.Abs((z2 - c3) / a3)), 2*b3 ));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment