Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- namespace WindowsFormsApplication5
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- //Метод
- public double Method(double x, double a)
- {
- double l;//Переменная в которой будет лежать ответ
- //Первое условие
- if (0 <= x & x <= 1)
- {
- //Ищем минимум согласно заданию
- l = (x - a) / x;
- if (l > Math.Sqrt(a) + x)
- {
- l = Math.Sqrt(a) + x;
- }
- if (l > Math.Pow(Math.Sin(x), 2.0))
- {
- l = Math.Pow(Math.Sin(x), 2.0);
- }
- }
- else
- {
- //Второе условие
- if (x < 0)
- {
- //Ищем максимум согласно заданию
- l = x;
- if (l < Math.Pow(a, x))
- {
- l = Math.Pow(a, x);
- }
- }
- //Ответ если 1ое и 2ое условия не соблюдены
- else
- {
- l = 0;
- }
- }
- return l;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- double x,a,l;
- x = Convert.ToDouble(textBox1.Text);
- a = Convert.ToDouble(textBox2.Text);
- l = Method(x, a);
- textBox3.Text=Convert.ToString(l);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement