Untitled

Jan 2nd, 2020
480
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Public Class Triangle
2.
3.     Public side1 as double
4.     Public side2 as double
5.     Public side3 as double
6.
7.     Public Area as double
8.     Public Perimeter As double
9.
10.         Public Sub setSide1 (ByVal w As double)
11.               side1 = w
12.               Console.WriteLine(w)
13.         End Sub
14.
15.         Public Sub setSide2 (ByVal w As double)
16.               side2 = w
17.               Console.WriteLine(w)
18.         End Sub
19.
20.         Public Sub setSide3 (ByVal w As double)
21.               side3 = w
22.               Console.WriteLine(w)
23.         End Sub
24.
25.         Public Sub setArea ()
26.
27.             Dim halfArea as double
28.             halfArea = (side1 + side2 + side3) / 2
29.             Area = halfArea * (halfArea-side1)* (halfArea-side2)* (halfArea-side3)
30.             Console.WriteLine("Лицето на този триъгълник е: " & Area)
31.
32.         End Sub
33.
34.         Public Sub setPerimeter ()
35.
36.             Perimeter = side1 + side2 + side3
37.             Console.WriteLine("Периметърът на този триъгълник е: " & Perimeter)
38.
39.         End Sub
40.
41.
42.        Public Function getSide1() as double
43.        Return side1
44.        End Function
45.
46.        Public Function getSide2() as double
47.        Return side2
48.        End Function
49.
50.        Public Function getSide3() as double
51.        Return side3
52.        End Function
53.
54.        Public Function getArea() as double
55.        Return Area
56.        End Function
57.
58.        Public Function getPerimeter() as double
59.        Return Perimeter
60.        End Function
61.
62. End Class
63.
64.
65.
66.     Sub Main()
67.
68.         Console.WriteLine("Въведете брои на точки(кратен на 3):")
69.         Dim MyGivenNumber as Integer
71.
72.         Dim triangleNum as Integer = MyGivenNumber/3
73.         Console.WriteLine("Броят на получините триъгълници е: " & triangleNum)
74.         Dim triangleData (triangleNum-1) As Triangle
75.         Dim max As Integer = triangleNum-1
76.
77.          For value As Integer  = 0 To max step +1
78.
79.             Console.WriteLine("------")
80.
81.             triangleData (value) = New Triangle()
82.             Console.WriteLine("На колко е равна първата страна на триъгълник номер " & value+1)
84.             Console.WriteLine("На колко е равна втората страна на триъгълник номер " & value+1)
86.             Console.WriteLine("На колко е равна третата страна на триъгълник номер " & value+1)
88.             triangleData(value).setArea()
89.             triangleData(value).setPerimeter()
90.         Next
91.
92.
93.         Console.WriteLine("-/-/-/-/-/-")
94.
95.         dim ss as Integer = theSlowestArea(triangleData, max)
96.         Console.WriteLine(ss)
97.
98.
99.     End Sub
100.
101.     Function theSlowestArea(ByVal triangleData() As Triangle, ByVal triangleNum As Integer) As Integer
102.
103.         Dim int_max as Integer = 90946
104.         Dim theNumInTheArray as Integer = 0
105.
106.         For n as Integer = 0 to triangleNum step+1
107.
108.              If triangleData(n).getArea() < int_max Then
109.                 int_max = triangleData(n).getArea()
110.                 theNumInTheArray = n
111.             End If
112.
113.         Next
114.         return theNumInTheArray- 1
115.     End Function
116.
117.     Function theBiggestArea(ByVal triangleData() As Triangle, ByVal triangleNum As Integer) As Integer
118.
119.         Dim int_mim as Integer = -90946
120.         Dim theNumInTheArray as Integer = 0
121.
122.         For n as Integer = 0 to triangleNum step+1
123.
124.              If triangleData(n).getArea() > int_min Then
125.                 int_min = triangleData(n).getArea()
126.                 theNumInTheArray = n
127.             End If
128.
129.         Next
130.         return theNumInTheArray- 1
131.     End Function
132.
133.     Function theSlowestPerimeter(ByVal triangleData() As Triangle, ByVal triangleNum As Integer) As Integer
134.
135.         Dim int_max as Integer = 90946
136.         Dim theNumInTheArray as Integer = 0
137.
138.         For n as Integer = 0 to triangleNum step+1
139.
140.              If triangleData(n).getPerimeter() < int_max Then
141.                 int_max = triangleData(n).getPerimeter()
142.                 theNumInTheArray = n
143.             End If
144.
145.         Next
146.         return theNumInTheArray- 1
147.     End Function
148.
149.     Function theBiggestPerimeter(ByVal triangleData() As Triangle, ByVal triangleNum As Integer) As Integer
150.
151.         Dim int_mim as Integer = -90946
152.         Dim theNumInTheArray as Integer = 0
153.
154.         For n as Integer = 0 to triangleNum step+1
155.
156.              If triangleData(n).getPerimeter() > int_min Then
157.                 int_min = triangleData(n).getPerimeter()
158.                 theNumInTheArray = n
159.             End If
160.
161.         Next
162.         return theNumInTheArray- 1
163.     End Function
164.
165. End Module
RAW Paste Data