2-Dimensional Array

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

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

View Full Document Right Arrow Icon
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:
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5
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

This note was uploaded on 09/18/2011 for the course ENGR 160 taught by Professor Sengupta during the Fall '07 term at Iowa State.

Page1 / 5

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

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online