Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.ComponentModel;
- using System.IO;
- using System.Windows.Forms;
- using System.Windows.Forms.DataVisualization.Charting;
- namespace Tabulation
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox3_TextChanged(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
- {
- MessageBox.Show("Заполни все пустые поля", "Постой");
- return;
- }
- string Path = Application.StartupPath + @"\OUTPUT.txt";
- double a = Convert.ToDouble(textBox1.Text);
- double b = Convert.ToDouble(textBox3.Text);
- double h = Convert.ToDouble(textBox2.Text);
- if (a>b)
- {
- MessageBox.Show("Некорректное значение a или b", "Постой");
- return;
- }
- double y;
- FileStream file = new FileStream(Path, FileMode.OpenOrCreate);
- StreamWriter stream = new StreamWriter(file);
- stream.WriteLine("Тагирова Валерия \n! X ! Y !");
- // График
- this.chart1.Series[0].Points.Clear();
- while (a<=b)
- {
- if (a >= 0)
- {
- y = Math.Round(Math.Pow(a, 6.5) / Math.Exp(Math.Cos(a)), 3);
- stream.WriteLine("! " + a + " ! " + y + " !");
- this.chart1.Series[0].Points.AddXY(a, y);
- }
- else
- {
- stream.WriteLine("! " + a + " ! - !");
- }
- a = Math.Round(a + h, 3);
- }
- chart1.SaveImage(Application.StartupPath + @"\OUTPUT.png", ChartImageFormat.Png);
- stream.Close();
- file.Close();
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e) //a
- {
- if (Char.IsNumber(e.KeyChar) || e.KeyChar == ',' || e.KeyChar == '\b' || e.KeyChar == '-') return;
- else
- e.Handled = true;
- }
- private void textBox2_KeyPress(object sender, KeyPressEventArgs e) //h
- {
- if (Char.IsNumber(e.KeyChar) || e.KeyChar == ',' || e.KeyChar == '\b') return;
- else
- e.Handled = true;
- }
- private void textBox3_KeyPress(object sender, KeyPressEventArgs e) //b
- {
- if (Char.IsNumber(e.KeyChar) || e.KeyChar == ',' || e.KeyChar == '\b' || e.KeyChar == '-') return;
- else
- e.Handled = true;
- }
- private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
- {
- }
- private void chart1_Click(object sender, EventArgs e)
- {
- }
- private void label3_Click(object sender, EventArgs e)
- {
- }
- private void label2_Click(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement