Computer Science, asked by karanangi3835, 1 year ago

Write a QBasic program that can read and store three vectors A, B, and C. The user should ask for the vector sizes (use different sizes of the vectors) then compute the followings: Read and print each vector, Use one general subroutine for this task. Calculate and print the merging vector H where H=[A(1),B(1),C(1),A(2),B(2),C(2),A(3),B(3),C(3),……….],. Use subroutine for this task. Determine and print the intersection elements of (A,B), (A,C) and (B,C), use only global subroutine for any intersection determination. It is required to insert number 6 in the 2rd position in vector A while number 45 in the 3rd position in vector B while number 32 is inserted into 4th position in vector C. Then print the vectors after inserting these numbers. qbasic

Answers

Answered by mohamedkhaled246246
1

Answer:

CLS

DIM SHARED a(10), b(10), c(10), h(30), x, y, z

CALL reading

CALL merg

PRINT "the inter. elements between vectors A & B"

CALL inter(a(), b(), x, y)

PRINT "the inter. elements between vectors A & C"

CALL inter(a(), c(), x, z)

PRINT "the inter. elements between vectors C & B"

CALL inter(c(), b(), y, z)

CALL insert(5, 3, a(), x)

CALL insert(41, 4, b(), y)

CALL insert(32, 2, c(), z)

SUB reading

INPUT "enter the vectors size A & B & C"; x, y, z

PRINT "enter vector numbers A"

FOR o = 1 TO x

INPUT a(o)

NEXT: CLS

PRINT "enter vector numbers B"

FOR o = 1 TO y

INPUT b(o)

NEXT: CLS

PRINT "enter vector numbers C"

FOR o = 1 TO z

INPUT c(o)

NEXT: CLS

PRINT "vector A"

FOR i = 1 TO x

PRINT a(i);

NEXT: PRINT

PRINT "vector B"

FOR i = 1 TO y

PRINT b(i);

NEXT: PRINT

PRINT "vector C"

FOR i = 1 TO z

PRINT c(i);

NEXT: PRINT

END SUB

SUB merg

FOR i = 1 TO x

h(i) = a(i)

NEXT

FOR i = 1 TO y

h(i + x) = b(i)

NEXT

FOR i = 1 TO z

h(i + x + z) = c(i)

NEXT

PRINT "The merging of the 3 voctors H"

FOR i = 1 TO x + y + z - 1

FOR u = 1 + i TO x + y + z

IF h(i) = h(u) THEN GOTO 2

NEXT

PRINT h(i);

2 NEXT: PRINT

END SUB

SUB inter (f(), n(), a, b)

FOR i = 1 TO a

FOR u = 1 TO b

IF f(i) = n(u) THEN PRINT f(i): g = g + 1

NEXT: NEXT

IF g = 0 THEN PRINT "No commen elements"

END SUB

SUB insert (nu, po, v(), m)

LET s = v(po): v(po) = nu

FOR i = po + 2 TO m + 1

v(i) = v(i - 1)

NEXT

v(po + 1) = s

PRINT "the vector after inserting the no."

FOR u = 1 TO m + 1

PRINT v(u);

NEXT: PRINT

END SUB

Explanation:


ramboshadow888: ايه الارقام اللي ممكن اجرب البرنامج بيها
Similar questions