2.5 ...
This presentation is the property of its rightful owner.
Sponsored Links
1 / 23

2.5 ตัวแปรชุดมิติเดียวและตัวแปรชุดสองมิติ PowerPoint PPT Presentation


  • 84 Views
  • Uploaded on
  • Presentation posted in: General

2.5 ตัวแปรชุดมิติเดียวและตัวแปรชุดสองมิติ. ตัวแปรที่ใช้ในผังโปรแกรม ตัวแปรเดี่ยว การตั้งชื่อตัวแปรเพื่อใช้แทนข้อมูล เพียง 1 จำนวน เท่านั้น เช่น A , B , X , TOT, NAME เป็นต้น ตัวแปรชุด (ARRAY) การตั้งชื่อตัวแปรในหน่วยความจำที่ใช้ชื่อเพียงตัวเดียว

Download Presentation

2.5 ตัวแปรชุดมิติเดียวและตัวแปรชุดสองมิติ

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


2 5

2.5

    • 1

  • A , B , X , TOT, NAME

    • (ARRAY)

  • X(1) , X(2), X(3)


2 5

(ONE-DIMENSION ARRAY)

1

2

3

4

5

X(3)

X

X

X(3)

X(5)

X(5)

(Subscript)


2 5

(TWO-DIMENSION ARRAY)

Matrix 2

1 2 3

X

1

2

3

4

5

6

X(2,3)

X(5,3)


2 5

    • [C]mxn = [A]mxn + [B]mxn

  • [C]mxn = [A]mxn * [B]mxn

  • a[3][2]

  • a11 a12

    a21 a22

    a31 a32


    2 5

    Flowchart

    READ

    M,N

    I 1 M

    I = 0

    I = I + 1

    J = 0

    A(I,J)

    J 1 N

    I

    J = J + 1

    Read

    A(I,J)

    no

    J = N?

    yes

    no

    I = M?

    yes

    A[I,J]


    2 5

    Read

    X(I)

    I = 110

    10 X(1) X(10)

    Print

    X(I)

    I = 110

    X(1) X(10)


    2 5

    2

    Read

    A(I,J)

    I = 1,2M

    J = 1,2.N

    M X(1) X(M)

    Print

    A(I,J)

    I = 1,2M

    J = 1,2.N

    X(1) X(M)


    2 5

    • 12

      • N

    • 3 3 5 1

    3 5 1

    3 5 1

    MAX

    MIN

    MIN

    MAX

    3 5 1

    3 5 1

    MIN

    MAX

    MAX

    MIN

    2

    1

    3

    4


    2 5

      • N =

      • X(I) = I

      • MAX = (Maximum)

      • MIN = (Minimum)


    2 5

    START

    Read

    N

    Read X(I)

    i = 1N

    i = 1

    MIN=X(i)

    MAX=X(i)

    1

    2

    Flowchart

    ()


    2 5

    2

    1

    No

    Yes

    i < N

    Print

    MAX

    MIN

    i = i + 1

    No

    Yes

    X(i)>MAX?

    STOP

    MAX=X(i)

    Yes

    No

    X(i)<MIN?

    MIN=X(i)


    2 5

    13

    (Sort) 999

    5 1

    1 5

    a[L+1]--> a[L]

    temp --> a[L+1]

    a[L]

    a[L+1]

    a[L]

    temp

    5 1

    1 1

    1 5

    a[L] = a[L+1]

    a[L+1]=temp

    Temp = a[L]

    Temp

    5


    2 5

    a(i) = i

    i =

    CHECK =

    CHECK = 1 1 ()

    CHECK = 0 ()

    Temp =

    N =

    L =


    2 5

    Flowchart

    START

    i = 0

    i = i + 1

    Read a[i]

    a[i]=999

    N= i - 1

    CHECK = 1

    1

    N

    Y

    2

    Check=1

    L = 1 TO N

    Print

    a[L]

    STOP

    ()


    2 5

    2

    L=1

    CHECK = 0

    N

    Y

    L < N

    N

    Y

    a[L]>a[L+1]

    Temp=a[L]

    a[L]=a[L+1]

    a[L+1]=Temp

    CHECK = 1

    1

    L = L + 1


    2 5

    c11 c12 c13

    c21 c22 c23

    a11 a12 a13

    a21 a22 a23

    b11 b12 b13

    b21 b22 b23

    +

    =

    2*3

    2*3

    2*3

    • 14

    • 2

      • [A]mxn = [B]mxn + [C]mxn

  • 2*3

    • aij = bij + cij


  • 2 5

    START

    Read m,n

    Read Aij

    i = 1,,m

    j = 1,,n

    Read Bij

    i = 1m

    j = 1n

    j = 0

    1

    Flowchart

    ()


    2 5

    1

    j = j + 1

    i = 0

    2

    Print Cij

    i = 1m

    j = 1n

    i = i + 1

    i = i + 1

    Cij = Aij + Bij

    STOP

    i = m?

    N

    Y

    j = n?

    N

    Y

    2

    Flowchart


    2 5

    15

    SD2 =

    (Xi - X)2

    N-1

    • Xi

    • X

    • N

      • Input :

      • Output :

      • : -

      • -


    2 5

      • i =

      • score =

      • SUM =

      • X =

      • TOT =

      • ( (Xi - X)2)

      • SD2 =


    2 5

      • 1. (score) loop sum array

      • 2.

      • 3. loop SUM(Xi - X)2

      • 4. (Xi - X)2

    • N-1

      • 5.


    2 5

    START

    i = 0

    SUM = 0

    TOT =0

    Read score

    Yes

    Score<>999?

    No

    i = i + 1

    N = i

    X(i) = score

    SUM = SUM+score

    X=SUM/N

    Read score

    1

    Flowchart

    ()


    2 5

    1

    i = 0

    i = i + 1

    TOT=TOT+(X(i)-X)2

    No

    i = N?

    Yes

    SD2=TOT/(N-1)

    Print SD2

    END


  • Login