CyberArmy University | Open Source Institute | CyberArmy Intelligence & Security | CyberArmy Services & Projects

for reference


[Replies] [Reply] [View by Thread] [Help]
[Back To Programming]

Posted by Ker sefo On 2008-09-05 06:07:28
In Reply to Programming Challenge 4 Posted by Delta Cpt dopel On 2008-08-01 17:43:54

Ker
Ker sefo


Dim line, column, coefMin, coefMax, lineMin, lineMax, colMin, colMax, currentLine

line = 0
column = 0

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("result.txt", True)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("stories.txt", 1)

Do Until objFile.AtEndOfStream

    line = line + 1
    currentLine = objFile.Readline
    column = Len(currentLine)

    Call doCoef(line, column)

    column = 0

Loop

a.WriteLine("Max coef: " & coefMax & " at line: " & lineMax & " and num of chars: " & colMax)
a.WriteLine("Min coef: " & coefMin & " at line: " & lineMin & " and num of chars: " & colMin)

a.Close
objFile.Close

Public Function doCoef(Byval line, Byval column)
    If line = 1 Then
	lineMin = line
	lineMax = line
	colMin = column
	colMax = column
	coefMax = line * column
	coefMin = line * column
    Elseif line > 1 Then
	If line * column > coefMax Then
	    coefMax = line * column
	    lineMax = line
	    colMax = column
	Elseif line * column < coefMin Then
	    coefMin = line * column
	    lineMin = line
	    colMin = column
	End If
    End If
End Function
result:
Max coef: 178710 at line: 322 and num of chars: 555
Min coef: 0 at line: 6 and num of chars: 0



Replies:


Guest:
Subject:
Message:
Signature:
Optional Image Link:
http://

CyberArmy::Forum v0.6
Generated In 0.00640 seconds


About Us | Privacy Policy | Mission Statement | Help