{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2-Dimensional Array

# 2-Dimensional Array - Input#1 Original(R C Changed(R C =...

This preview shows pages 1–5. Sign up to view the full content.

Problem Statement: Write a program that will receive a set of numbers as a two-dimensional array. Have the program find the largest value in each row and switch the largest number with the first number. Solution:

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Option Explicit Private Sub CommandButton1_Click() Dim Original(1 To 100, 1 To 100) As Single, Changed(1 To 100, 1 To 100) As Single, Big(1 To 100) As Single
Dim i As Integer, j As Integer, R As Single, C As Single Open ("C:\Users\Cooper\Desktop\Large.txt") For Input As 1 Open ("C:\Users\Cooper\Desktop\LargeOut.txt") For Output As 2 Input #1, i, j For R = 1 To i For C = 1 To j
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Input #1, Original(R, C) Changed(R, C) = Original(R, C) Big(R) = Original(R, 1) Next C Next R For R = 1 To i For C = 1 To j If (Original(R, C) > Big(R)) Then Big(R) = Original(R, C) Next C Next R For R = 1 To i For C = 1 To i If (Changed(R, C) > Big(R)) Then Changed(R, C) = Changed(R, 1) Changed(R, 1) = Big(R) End If Next C Next R Print #2, "Original Array" For R = 1 To i For C = 1 To j Print #2, Original(R, C), Next C Print #2, Next R Print #2, Print #2, "Switched Array" For R = 1 To i For C = 1 To j Print #2, Changed(R, C), Next C Print #2, Next R Close End Sub...
View Full Document

{[ snackBarMessage ]}