Jump to content

Pythagorean table


Recommended Posts

Ok, just from curiosity, there is any (easy) way to creating the Pythagor table? My solution muttley

#include <Array.au3>

Global $aNumbers[10][10]

;Array filling
For $i = 1 To UBound($aNumbers) - 1
    $aNumbers[$i][0] = $i
    $aNumbers[0][$i] = $i
Next

;Multiplying
For $i = 1 To UBound($aNumbers) - 1
    For $j = 1 To UBound($aNumbers) - 1
        $aNumbers[$i][$j] = $aNumbers[$i][0] * $aNumbers[0][$j]
    Next
Next

_ArrayDisplay($aNumbers)
Link to comment
Share on other sites

Ok, just from curiosity, there is any (easy) way to creating the Pythagor table? My solution muttley

#include <Array.au3>

Global $aNumbers[10][10]

;Array filling
For $i = 1 To UBound($aNumbers) - 1
    $aNumbers[$i][0] = $i
    $aNumbers[0][$i] = $i
Next

;Multiplying
For $i = 1 To UBound($aNumbers) - 1
    For $j = 1 To UBound($aNumbers) - 1
        $aNumbers[$i][$j] = $aNumbers[$i][0] * $aNumbers[0][$j]
    Next
Next

_ArrayDisplay($aNumbers)oÝ÷ Ûú®¢×z·¢¶+"ÞÍ{e¢Sê.¶­$²Ø^±©j̨º»ºÚ"µÍÚ[ÛYH    Ð^K]LÉÝÂØØ[   ÌÍØS[XÖÌLVÌLNÓ][Z[ÂÜ   ÌÍÚHHHÈPÝ[
    ÌÍØS[XÊHHBÜ    ÌÍÚHHÈPÝ[
    ÌÍØS[XÊHHBBIÌÍØS[XÖÉÌÍÚWVÌHH   ÌÍÚBBIÌÍØS[XÖÌVÉÌÍÚHH   ÌÍÚ  ÌÍØS[XÖÉÌÍÚWVÉÌÍÚHH ÌÍÚJÌÍÚBB^^Ð^^J   ÌÍØS[
Link to comment
Share on other sites

Corrected:

#include <Array.au3>

Local $aNumbers[10][10];Multiplying

For $i = 1 To UBound($aNumbers) - 1
    $aNumbers[$i][0] = $i
    $aNumbers[0][$i] = $i
    
    For $j = 1 To UBound($aNumbers) - 1
        $aNumbers[$i][$j] = $i * $j
    Next
Next

_ArrayDisplay($aNumbers)
Could have kept as:

#include <Array.au3>

Local $aNumbers[10][10];Multiplying
For $i = 1 To UBound($aNumbers) - 1
    For $j = 1 To UBound($aNumbers) - 1
        $aNumbers[$i][0] = $i
        $aNumbers[0][$i] = $i
        $aNumbers[$i][$j] = $i*$j     
    Next
Next

_ArrayDisplay($aNumbers)

Either all, it works the same muttley

Link to comment
Share on other sites

  • Moderators

Could have kept as:

#include <Array.au3>

Local $aNumbers[10][10];Multiplying
For $i = 1 To UBound($aNumbers) - 1
    For $j = 1 To UBound($aNumbers) - 1
        $aNumbers[$i][0] = $i
        $aNumbers[0][$i] = $i
        $aNumbers[$i][$j] = $i*$j     
    Next
Next

_ArrayDisplay($aNumbers)

Either all, it works the same muttley

The output might be the same... but it certainly does Not work the same.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Bert

As say SmOke_N your example not work the same, also your example do slowed work. Why need to set same value into this array 9 time

$aNumbers[$i][0] = $i
$aNumbers[0][$i] = $i

muttley

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...