Технический форум

Технический форум (http://www.tehnari.ru/)
-   Помощь студентам (http://www.tehnari.ru/f41/)
-   -   Нужна помощь в написании программы на VB 2008 (http://www.tehnari.ru/f41/t41756/)

Alex0161 07.11.2010 14:42

Нужна помощь в написании программы на VB 2008
 
Тема: Создание класса, его сойств и методовов. Приграммирование структур витвления

a+b+c/2*min{x,y,x+y/x-y}, если x<3

b-cx^2, если x>3 =f

y(a+b+c) в пртивном случае

KiD2 07.11.2010 19:52

Интересно, что все это значит .) Условие фиг поймешь что =) Решение наверное такое же надо
Наверное если икс равен трем нужно решить третье уравнение, если меньше первое, если больше второе.) "=f" а вот это похоже смайлик .) Хотя Я могу ошибаться)))

Большая просьба если хотите, чтобы люди Вам помогли, оформляйте чтобы было понятно... А не так чтобы догадываться)))

KiD2 07.11.2010 20:18

И да чуть не забыл .) Вам нужно консольное приложение или приложение Windows?

Alex0161 07.11.2010 21:06

Вложений: 4
23 вариант
и пример решения во Microsoft Visual Basic 2008 Express Edition

Alex0161 10.11.2010 20:41

ну кто нибудь поможет пожалуйста

AlexZir 10.11.2010 20:53

А что вам, собственно, непонятно? Загружайте среду разработки и вперед, если что-то не получится - отписывайтесь, выкладывайте свой листинг, тогда и получите помощь.

Alex0161 18.11.2010 18:17

построить таблицу и найти наименьшие значение функции y=f(x) при изменении на отрезке [a,b} c шагом h
Y=x+1/x. Отрезок [0.1,2.5], шаг h=0.1
у меня программа не строит график помогите найти ошибку
код программы:

Public Class Class1
Public a1, b1, h1
Public ReadOnly Property a() As Single
Get
Return a1
End Get
End Property
Public ReadOnly Property b() As Single
Get
Return b1
End Get
End Property
Public ReadOnly Property h() As Single
Get
Return h1
End Get
End Property
Public Sub inputF()
a1 = CSng(InputBox("введите начальное значение функции"))
b1 = CSng(InputBox("введите конечное значение функции"))
h1 = CSng(InputBox("введите шаг"))
End Sub

End Class

Public Class Form1
Dim put As Class1 = New Class1
Public dx, dy, a, b, h As Single
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, y, xmax, ymax, xmin, ymin, dx, dy, xm, xn As Single
Dim n As Integer
ymax = -1.0E+38 : ymin = 1.0E+38
xmax = -1.0E+38 : xmin = 1.0E+38
put.inputF()
a = put.a
b = put.b
h = put.h
TextBox2.Text = Str(a)
TextBox3.Text = Str(b)
TextBox4.Text = Str(h)
n = (b - a) / h ^ 2

x = a
For i As Integer = 1 To n
x += h
y = x + 1 / x
ListBox1.Items.Add(x)
ListBox2.Items.Add(y)
ListBox3.Items.Add(i)
If x < xmin Then
xmin = x
End If
If x > xmax Then
xmax = x
End If
If y < ymin Then
ymin = y : xm = x
End If
If y > ymax Then
ymax = y : xn = x
End If
Next
dx = Math.Abs(xmax - xmin)
dy = Math.Abs(ymax - ymin)
TextBox1.Text = "Наименьшее значение функции " & Str(ymin) & " при x= " & Str(xm) & vbCrLf & vbCrLf
TextBox1.Text = TextBox1.Text & "Наименьшее значение функции " & Str(ymin) & " при x= " & Str(xn) & vbCrLf
End Sub



Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Hide()
Form2.Show()
End Sub
End Class

Imports System.Math
Public Class Form2
Private Sub form2_paint(ByVal sender As Object, ByVal el As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim GF As System.Drawing.Graphics
GF = Label1.CreateGraphics
Dim GF2 As System.Drawing.Graphics
GF2 = Label2.CreateGraphics
Dim PenColor As New System.Drawing.Pen(System.Drawing.Color.Red)
GF.DrawLine(PenColor, 50, 0, 50, Label1.Height)
GF.DrawString("x", Label1.Font, Brushes.DarkRed, Label1.Width - 15, Label1.Height - 25)
GF.DrawLine(PenColor, 0, Label1.Height - 25, Label1.Width, Label1.Height - 25)
GF.DrawString("y", Label1.Font, Brushes.DarkRed, Label1.Width \ 2 - 100, 1)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim a, b, h, n, x, y, xmax, xmin, ymin, ymax, dx, dy As Single
Dim k As Integer, p As String
Dim GF As System.Drawing.Graphics
GF = Label1.CreateGraphics
Dim GF2 As System.Drawing.Graphics
GF2 = Label2.CreateGraphics
Dim PenColor As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim x1, y1, x2, y2, x3, y3, x4, y4, xa, ya As Single
a = Form1.a
b = Form1.b
h = Form1.h
n = (b - a) / h
ymax = -1.0E+38 : ymin = 1.0E+38
xmax = -1.0E+38 : xmin = 1.0E+38
x = a
For i As Integer = 1 To n
x += h
If x < xmin Then
xmin = x
End If
If x > xmax Then
xmax = x
End If
If y < ymin Then
ymin = y
End If
If y > ymax Then
ymax = y
End If
Next
dx = Abs(xmax - xmin)
dy = Abs(ymax - ymin)
x = a : k = 0
For i As Integer = 1 To n
x += h
y = x + 1 / x
xa = x * Label1.Width \ dx + 50 : ya = Label1.Height - y * Label1.Height \ dy - 50
GF.FillEllipse(Brushes.Red, xa, ya, 3, 7)
p = Mid(Str(x), 1, 4)
If i Mod 25 = 0 Then
GF.DrawString(p, Label1.Font, Brushes.DarkRed, xa - 30, Label1.Height - 20)
End If

If i Mod (n \ 5) = 0 And i > 32 Then
k += 1
Select Case k
Case 1
x1 = xa : y1 = ya
Case 2
x2 = xa : y2 = ya
Case 3
x3 = xa : y3 = ya
Case 4
x4 = xa : y4 = ya
End Select
End If
Next

y = ymax + 10 : h = dy / 5
For s As Single = 2 To Label1.Height Step 16
y -= h
p = Mid(Str(y), 1, 5)
GF.DrawString(p, Label1.Font, Brushes.DarkRed, 5, s)
Next

Dim points() As Point = {New Point(x1, y1), New Point(x2, y2), New Point(x3, y3), New Point(x4, y4)}
For t As Single = 0 To 2.5 Step 0.5
GF2.DrawCurve(Pens.Blue, points, t)
Next
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form1.Show()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
End Class

Alex0161 22.11.2010 23:48

Программа сделана
 
Вот код
Imports System.Math
Public Class Class1
Private a, b, c, x, r, f, y, t, v, z As Single
Public Property min() As Single
Get
Return v
End Get
Set(ByVal value As Single)
v = value
End Set
End Property
Public ReadOnly Property na() As Single
Get
Return a
End Get
End Property
Public ReadOnly Property nb() As Single
Get
Return b
End Get
End Property
Public ReadOnly Property nc() As Single
Get
Return c
End Get
End Property
Public ReadOnly Property nx() As Single
Get
Return x
End Get
End Property
Public ReadOnly Property ny() As Single
Get
Return y
End Get
End Property
Public Sub put()
a = Val(InputBox("enter a"))
b = Val(InputBox("enter b"))
c = Val(InputBox("enter c"))
x = Val(InputBox("enter x"))
y = Val(InputBox("enter y"))
t = (a + b + c) / 2
r = (x + y) / (x - y)
f = y * (a + b + c)

End Sub
Public Sub mindouble()
If x < 3 Then
If x < y Then
If x < r Then
z = x
Else
z = r
End If
End If
v = t * z
End If
If x > 0 And y > 1 Then
If x > y Then
v = y
Else
v = x
End If
End If
If x < 0 And y < 1 Then
v = y * f
End If
End Sub
Public Sub mindetur()

If x < y Then
If x < r Then
z = x
End If
End If
If x < 3 Then
v = t * z
End If
If x > 0 And y > 1 Then
If x < y Then
v = x
If x > y Then
v = y
End If
End If
End If
If x < 0 And y < 1 Then
v = y * f
End If
End Sub
End Class

Public Class Form1
Dim decision As Class1 = New Class1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
decision.put()
TextBox1.Text = CStr(decision.na)
TextBox2.Text = CStr(decision.nb)
TextBox3.Text = CStr(decision.nc)
TextBox4.Text = CStr(decision.nx)
TextBox5.Text = CStr(decision.ny)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
decision.mindouble()
TextBox7.Text = decision.min
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
decision.mindetur()
TextBox8.Text = decision.min
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
End
End Sub
End Class

saax 20.02.2011 00:15

Ребят,может помочь вот с этой задачей.Буду оч благодарен!

saax 20.02.2011 00:19

Вложений: 2
Вот задача!


Часовой пояс GMT +4, время: 16:16.

Powered by vBulletin® Version 4.5.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.