Sunteți pe pagina 1din 12

Sub pr_1()

Dim x As Integer
Dim y As Integer
Dim fx As Integer
Dim min As Integer
Dim max As Integer
Dim optiune As String
initial = 0
x = Val(InputBox("citeste x "))
y = Val(InputBox("citeste y "))
Select Case x
Case Is < -1
fx = 1 / 2 * ((x + Exp(x - 1)) + (x ^ 2 - 1))
Case Is >= 1
fx = Exp(x - 3) - 1
End Select
MsgBox "rezultatul primei functii este :" + Str(fx)
If x ^ 2 + y ^ 2 <= 1 Then
If x < y Then
min = x
Else
min = y
MsgBox "munarul minim este: " + Str(min)
End If
End If
If x ^ 2 + y ^ 2 > 1 Then
If x > y Then
max = x
Else
max = y
MsgBox "numarul maxim este: " + Str(max)
End If
End If
End Sub
Sub pr_2()
Dim a As Integer
Dim b As Integer, c As Integer, E As Integer, F As Integer, G As Integer, M As Integer
Dim n As Integer, p As Integer
Dim x1 As Double, x2 As Double, x3 As Double, arie As Double, sp As Double
a = Val(InputBox("A:"))
b = Val(InputBox("B:"))
c = Val(InputBox("C:"))
E = Val(InputBox("E:"))
F = Val(InputBox("F:"))
G = Val(InputBox("G:"))

M = Val(InputBox("M:"))
n = Val(InputBox("N:"))
p = Val(InputBox("P:"))
x1 = (-b * p + c * n) / (b * M - a * n)
x2 = (-b * G + c * F) / (b * E - a * F)
x3 = (-n * G + F * p) / (n * E - F * M)
'intersectiile formeaza un triunghi daca si numai daca suma dintre 2 intersectii este mai mare decat a 3a
If x1 + x2 > x3 Or x1 + x3 > x2 Or x2 + x3 > x1 Then
' pentru calculul ariei triunghiului dreptunghic
If x1 ^ 2 = x2 ^ 2 + x3 ^ 2 Then
arie = (x2 * x3) / 2
End If
If x2 ^ 2 = x1 ^ 2 + x3 ^ 2 Then
arie = (x1 * x3) / 2
End If
If x3 ^ 2 = x1 ^ 2 + x2 ^ 2 Then
arie = (x1 * x2) / 2
End If
End If
MsgBox "cele trei intersectii formeaza un triunghi dreptunghic si aria este" + Str(arie)
'pentru calculul ariei triunghiului isoscel
If x1 = x2 And x1 <> x3 Then
arie = x3 * (x2 ^ 2 - (x3 / 2) ^ 2) / 2
MsgBox "cele trei intersectii formeaza un triunghi isoscel si aria este" + Str(arie)
End If
If x1 = x3 And x1 <> x2 Then
arie = x2 * (x3 ^ 2 - (x2 / 2) ^ 2) / 2
MsgBox "cele trei intersectii formeaza un triunghi isoscel si aria este" + Str(arie)
End If
If x2 = x3 And x2 <> x1 Then
arie = x1 * (x3 ^ 2 - (x1 / 2) ^ 2) / 2
MsgBox "cele trei intersectii formeaza un triunghi isoscel si aria este" + Str(arie)
End If
'pentru calculul ariei triunghiului echilateral
If x1 = x2 And x2 = x3 And x3 = x1 Then
MsgBox "cele trei numere formeaza un triunghi echilateral"
arie = (x1 ^ 2 * Sqr(3)) / 4
Else
sp = (x1 + x2 + x3) / 2
arie = Sqr(sp * (sp - x1) * (sp - x2) * (sp - x3))
MsgBox "cele trei numere formeaza un triunghi oarecare"
MsgBox "intersectiile celor 3 drepte formeaza un triunghi oarecare si aria este " + Str(arie)
End If
End Sub
Sub pr_3()

Dim suma As Double


Dim i As Integer
Dim contor As Integer
Dim a As Integer
Dim b As Integer
Dim c As Integer
suma = Val(InputBox("citeste suma in bani: "))
s=0
If suma >= 500 Then
i = suma / 500
MsgBox "avem" + Str(i) + "banc de 500 lei"
If suma >= 100 Then
a = suma - (i * 500)
a = a / 100
MsgBox "avem" + Str(a) + "banc de 100 lei"
If suma > 50 Then
b = suma - (i * 500) - (a * 100)
b = b / 10
MsgBox "avem" + Str(b) + "banc de 50 lei"
Else
If suma = 50 Then
MsgBox "avem" + Str(suma / 50) + "banc de 50"
If suma > 10 Then
c = suma - (i * 500) - (a * 100) - (b * 50)
c = c / 10
MsgBox "avem" + Str(c) + "banc de 10"
Else
If suma = 10 Then
MsgBox "avem" + Str(suma / 10) + "banc de 10"
End If
End If
End If
End If
End If
End If
End Sub
Sub pr_9()
Dim text As String, y As String
text = InputBox("citeste textul") + "."
i = Len(text)
Do While i >= 1
y = y + Mid(text, i, 1)
i=i-1
Loop
MsgBox y

End Sub
Sub pr_10()
Dim x As Integer
Dim y As Integer
Dim z As Integer
x = InputBox("tastati primul numar: ")
y = InputBox("al 2lea numar: ")
z = InputBox("al 3lea numar: ")
If x + y > z Or x + z > y Or y + z > x Then
If x ^ 2 = y ^ 2 + z ^ 2 Or y ^ 2 = x ^ 2 + z ^ 2 Or z ^ 2 = x ^ 2 + y ^ 2 Then
MsgBox "cele trei numere formeaza un triunghi dreptunghic"
Else
If x = y And x <> z Or x = z And x <> y Or y = z And y <> x Then
MsgBox "cele trei numere formeaza un triunghi isoscel"
Else
If x = y And y = z And z = x Then
MsgBox "cele trei numere formeaza un triunghi echilateral"
Else
MsgBox "cele trei numere formeaza un triunghi oarecare"
End If
End If
End If
End If
End Sub
Sub pr_12()
Dim x As Integer
Dim y As Integer
Dim z As Integer
Dim v As Integer
Dim suma As Double
Dim prod As Double
x = InputBox(" primul numar: ")
y = InputBox("al 2lea numar: ")
z = InputBox("al 3lea numar: ")
v = InputBox(" al 4lea numar: ")
If x > 0 And y > 0 And z > 0 Then
If (x + y + z) Mod 2 = 0 Then
suma = x + y + z + v
MsgBox "suma celor 4 elemente este: " + Str(suma)
Else
prod = x * y * z * v
MsgBox "produsul celor 4 numere este:" + Str(prod)
End If
End If

If x > 0 And y > 0 And v > 0 Then


If (x + y + v) Mod 2 = 0 Then
suma = x + y + z + v
MsgBox "suma celor 4 elemente este: " + Str(suma)
Else
prod = x * y * z * v
MsgBox "produsul celor 4 numere este:" + Str(prod)
End If
End If
If x > 0 And z > 0 And v > 0 Then
If (x + z + v) Mod 2 = 0 Then
suma = x + y + z + v
MsgBox "suma celor 4 elemente este: " + Str(suma)
Else
prod = x * y * z * v
MsgBox "produsul celor 4 numere este:" + Str(prod)
End If
End If
If y > 0 And z > 0 And v > 0 Then
If (y + z + v) Mod 2 = 0 Then
suma = x + y + z + v
MsgBox "suma celor 4 elemente este: " + Str(suma)
Else
prod = x * y * z * v
MsgBox "produsul celor 4 numere este:" + Str(prod)
End If
End If
End Sub
Sub pr_4()
Dim i As Integer
Dim p As Double
Dim s As Integer
Const sir = "facultatea de inginerie"
i=1
s=0
For i = 1 To 25
If Mid(sir, i, 1) = "a" Or Mid(sir, i, 1) = "e" Or Mid(sir, i, 1) = "i" Or Mid(sir, i, 1) = "o" Or Mid(sir, i, 1) = "u" Then
s=s+1
End If
Next
i=i+1
p = s / 100 * 21
MsgBox "numarul de vocale din textul dat este" + Str(s)
MsgBox "numarul de vocale reprezinta " + Str(p) + "% din textul dat"

End Sub
Sub pr_7()
Dim x As Integer
Dim fx As Double
x = Val(InputBox("citeste x"))
Select Case x
Case -50 To -20
fx = -x ^ 2 - 1
Case -20 To -10
fx = x
Case -10 To 30
fx = (-1 / 4) * x - (5 / 4)
Case 30 To 50
fx = x ^ 2 - 5
End Select
MsgBox fx
End Sub
Sub pr_13()
Dim x As Byte
Dim y As Byte
Dim z As Byte
Dim fractie As Double
x = Val(InputBox("citeste x: "))
y = Val(InputBox("citeste y: "))
z = Val(InputBox("citeste z: "))
If x Mod z = 0 And y Mod z = 0 Then
fractie = (x / z) / (y / z)
MsgBox fractie
Else
MsgBox "fractia NU se simplifica cu z"
End If
End Sub
Sub pr_15()
Dim p As Integer
Dim d1 As Integer
Dim d2 As Integer
Dim c As Integer
Dim t1 As Integer
Dim t2 As Integer
Dim optiune As String
Dim arie As Double

optiune = InputBox(" pentru calcularea ariei unui patrat introduceti litera p; pentru calcularea ariei unui dreptunghi
introduceti litera d; pentru calcularea ariei unui cerc introduceti litera c iar pentru calcularea ariei unui triunghi
introduceti litera t")
If Trim(optiune) = "p" Then
p = InputBox("citeste p: ")
arie = p * p
MsgBox "aria patratului este " + Str(arie)
End If
If Trim(optiune) = "d" Then
d1 = InputBox("citeste d1: ")
d2 = InputBox("citeste d2: ")
arie = d1 * d2
MsgBox "aria dreptunghiului este" + Str(arie)
End If
If Trim(optiune) = "c" Then
c = InputBox("citeste c: ")
Const pi = 3.1415
arie = pi * c ^ 2
MsgBox "aria cercului este: " + Str(arie)
End If
If Trim(optiune) = "t" Then
t1 = InputBox("citeste t1: ")
t2 = InputBox("citeste t2: ")
arie = t1 * t2 / 2
MsgBox "aria triunghiului este: " + Str(arie)
End If
End Sub
Sub pr_16()
Dim a As Integer
Dim b As Integer
Dim c As Integer
a = Val(InputBox("citeste a: "))
b = Val(InputBox("citeste b: "))
c = Val(InputBox("citeste c: "))
If b - a = c - b Then
MsgBox " cele trei numere formeaza o progresie aritmetica si ratia este " + Str(b - a)
Else
MsgBox "cele 3 numere nu formeaza o progresie aritmetica"
End If
End Sub
Sub pr_18()
Dim nr As Variant
Dim y As Variant
nr = InputBox("citeste numarul: ")

i = Len(nr)
Do While i >= 1
y = y + Mid(nr, i, 1)
i=i-1
Loop
MsgBox "palindromul numarului este " + y
If y = nr Then
MsgBox "palindromul este egal cu numarul " + y
Else
MsgBox "numarul nu este egal cu palindromul lui"
End If
End Sub
Sub pr_19()
Dim a As Integer, b As Integer, c As Integer
Dim d As Integer, E As Integer, F As Integer
Dim x As Double, y As Double
a = InputBox("citeste a: ")
b = InputBox("citeste b: ")
c = InputBox("citeste c: ")
d = InputBox("citeste d: ")
E = InputBox("citeste e: ")
F = InputBox("citeste f: ")
If a = 0 And b = 0 And c = 0 Or a = 0 And b = 0 And c = 0 Then
MsgBox "sistemul nu se poate calcula"
End If
If a = 0 And b = 0 And c = 0 And d = 0 And E = 0 And F = 0 Then
MsgBox "sistem nedeterminat"
End If
If a = 0 And b = 0 Or d = 0 And E = 0 Then
MsgBox "sistemul nu se poate calcula"
End If
If a = 0 Then
x = (b * F - c * E) / b * d
y=c/b
MsgBox "x are valoarea " + Str(x) + " si y are valoarea " + Str(y)
End If
If a <> 0 And b <> 0 And c <> 0 And d <> 0 And E <> 0 And F <> 0 Then
y = (a * F - c * d) / (a * E - d * b)
x = (c * (a * E - b * d) - b * (a * F - c * d)) / (a * (a * E - b * d))
MsgBox "x are valoarea " + Str(x) + " si y are valoarea " + Str(y)
End If
End Sub
Sub pr_17()

optiune = InputBox("tastati unul din urmatorii ani pentru ai transcrie in litere: 1914, 1939, 1989, 2000, 2007")
Const an1 = "1914"
Const an2 = "1939"
Const an3 = "1989"
Const an4 = "2000"
Const an5 = "2007"
If Trim(optiune) = "1914" Then
MsgBox "anul 1914 scris in litere este o mie noua sute paisprezece"
End If
If Trim(optiune) = "1939" Then
MsgBox "anul 1939 scris in litere este o mie noua sute treizeci si noua"
End If
If Trim(optiune) = "1989" Then
MsgBox "anul 1989 scris in litere este o mie noua sute optzeci si noua"
End If
If Trim(optiune) = "2000" Then
MsgBox "anul 2000 scris in litere: doua mii"
End If
If Trim(optiune) = "2007" Then
MsgBox "anul 2007 scris in litere: doua mii sapte"
End If
End Sub
Sub pr_20()
Dim nr As Integer
Dim a As Single, b As Single, c As Single, d As Single
nr = InputBox("citeste numarul de 4 cifre: ")
'a,b,c,d reprezinta cifrele numarului
a = Left(nr, 1)
b = Mid(nr, 2, 1)
c = Mid(nr, 3, 1)
d = Right(nr, 1)
If a > b And a > c And a > d Or a = b And a > c And a > d Or a = c And a > b And a > d Or a = d And a > b And a > c
Or a = b And a = c And a > d Or a = c And a = d And a > b Or a = b And a = d And a > c Then
MsgBox "valoarea maxima dintre cele 4 cifre este" + Str(a)
End If
If b > a And b > c And b > d Or b = c And b = d And b > a Or b = c And b > a And b > d Or b = d And b > a And b >
c Then
MsgBox "valoarea maxima dintre cele 4 cifre este: " + Str(b)
End If
If c > a And c > b And c > d Or c = d And c > a And c > b Then
MsgBox "valoarea maxima dintre cele 4 cifre este: " + Str(c)
End If
If d > a And d > b And d > c Then
MsgBox "valoarea maxima dintre cele 4 cifre este: " + Str(d)

End If
If a < b And a < c And a < d Or a = b And a = c And a < d Or a = b And a < c And a < d Or a = c And a < b And a < d
Or a = d And a < b And a < c Or a = c And a = d And a < b Or a = b And a = d And a < c Then
MsgBox "valoarea minima este: " + Str(a)
End If
If b < a And b < c And b < d Or b = c And b < a And b < d Or b = d And b < a And b < c Or b = c And b = d And b <
a Then
MsgBox "valoarea minima este: " + Str(b)
End If
If c < a And c < b And c < d And c = d And c < a And c < b Then
MsgBox "valoarea minima este: " + Str(c)
End If
If d < a And d < b And d < c Then
MsgBox "valoarea minima este: " + Str(d)
End If
If a = b And a = c And a = d Then
MsgBox "nu se poate afla valoarea minima sau maxima"
End If
suma = Val(a + b + c + d)
MsgBox "suma celor 4 cifre este" + Str(suma)
End Sub
Sub pr_14()
Dim an As Integer
an = InputBox("citeste anul: ")
If an Mod 4 = 0 And an Mod 100 <> 0 Then
MsgBox "anul este bisect"
Else
MsgBox "anul nu este bisect"
End If
End Sub
Sub pr_11()
Dim n As Integer
Dim i As Integer
i=2
n = InputBox("citeste numarul: ")
If n Mod i = 0 Then
div1 = i
i=i+1
If n Mod i Then
div2 = i
i=i+1
End If
MsgBox div1 + div2
End If

End Sub
Sub pr_8()
'numerele pitagorice sunt de forma (a,b,c) unde a^2=b^2+c^2
Dim a As Integer, b As Integer, c As Integer
Dim x As Integer
x = InputBox("citeste x: ")
For a = 1 To x
For b = 1 To x
For c = 1 To x
If a ^ 2 = b ^ 2 + c ^ 2 Or b ^ 2 = a ^ 2 + c ^ 2 Or c ^ 2 = a ^ 2 + b ^ 2 Then
MsgBox "sunt numere pitagorice (" + Str(a) + "," + Str(b) + "," + Str(c) + ")"
End If
Next
Next
Next
End Sub
Sub pr_6()
Dim a As Integer, b As Integer
Dim nprim As Integer, i As Integer, j As Integer
Dim flag As Boolean
x = Val(InputBox("citeste x: "))
y = Val(InputBox("citeste y: "))
suma = 0
For i = x To y
flag = False
For j = 2 To i - 1
If i Mod j = o Then
flag = True
End If
Next
If flag = False Then
MsgBox i
suma = i + suma
End If
Next
MsgBox "suma este" + Str(suma)
End Sub
Sub pr_5()
Dim i As Integer
suma = 0
' 2^3+4^3+....+20^3
For i = 2 To 20
If i Mod 2 = 0 Then

suma = i ^ 3 + suma
End If
Next
MsgBox "suma este" + Str(suma)
'3^3+6^3+...+30^3
For i = 3 To 30
If i Mod 3 = 0 Then
suma = i ^ 3 + suma
End If
Next
MsgBox "suma este" + Str(suma)
'5^3+10^3+...+50^3
For i = 5 To 50
If i Mod 5 = 0 Then
suma = i ^ 3 + suma
End If
Next
MsgBox "suma este" + Str(suma)
End Sub