540 likes | 734 Views
Chapter 7. ARRAYS. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. ARRAY DECLARATIONS. One Dimensional (Vector) INTEGER MONTH(12). 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 31. 28. 31. 30. 31. 30. 31. 31. 30. 31. 30. 31. ARRAY DECLARATIONS. One Dimensional (Vector)
E N D
Chapter 7 ARRAYS
1 2 3 4 5 6 7 8 9 10 11 12 ARRAY DECLARATIONS • One Dimensional (Vector) INTEGER MONTH(12)
1 2 3 4 5 6 7 8 9 10 11 12 31 28 31 30 31 30 31 31 30 31 30 31 ARRAY DECLARATIONS • One Dimensional (Vector) INTEGER MONTH(12)
A C . . . THE DATA STATEMENT INTEGER A(4), B(3,4), C(3,40), D(30,40) DATA A /22,12,8,3/ DATA B /1,2,3,4,5,6,7,8,9,10,11,12/ DATA C /3*0, 39*(1,2,3)/ Fill in the blank arrays: B
A C 22 . 12 . 8 . 3 THE DATA STATEMENT INTEGER A(4), B(3,4), C(3,40), D(30,40) DATA A /22,12,8,3/ DATA B /1,2,3,4,5,6,7,8,9,10,11,12/ DATA C /3*0, 39*(1,2,3)/ Fill in the blank arrays: B
A C 22 . 12 . 8 . 3 THE DATA STATEMENT INTEGER A(4), B(3,4), C(3,40), D(30,40) DATA A /22,12,8,3/ DATA B /1,2,3,4,5,6,7,8,9,10,11,12/ DATA C /3*0, 39*(1,2,3)/ Fill in the blank arrays: B
A C 22 0 1 1 . 1 1 12 0 2 2 . 2 2 8 0 3 3 . 3 3 3 THE DATA STATEMENT INTEGER A(4), B(3,4), C(3,40), D(30,40) DATA A /22,12,8,3/ DATA B /1,2,3,4,5,6,7,8,9,10,11,12/ DATA C /3*0, 39*(1,2,3)/ Fill in the blank arrays: B
D . … . … . THE DATA STATEMENT INTEGER A(4), B(3,4), C(3,40), D(30,40) DATA D /1200*0/ Fill in the blank arrays:
D 0 0 0 0 0 0 0 0 . 0 0 … . … 0 0 0 . 0 0 0 0 0 0 0 THE DATA STATEMENT INTEGER A(4), B(3,4), C(3,40), D(30,40) DATA D /1200*0/ Fill in the blank arrays:
I J X THE DATA STATEMENT INTEGER I, J REAL X(4) DATA I, J, X /1, 2, 1.5, 3.0, 2.5, 5.5/ Fill in the blank arrays:
I J X 1 THE DATA STATEMENT INTEGER I, J REAL X(4) DATA I, J, X /1, 2, 1.5, 3.0, 2.5, 5.5/ Fill in the blank arrays:
I J X 1 2 THE DATA STATEMENT INTEGER I, J REAL X(4) DATA I, J, X /1, 2, 1.5, 3.0, 2.5, 5.5/ Fill in the blank arrays:
I J X 1 2 1.5 3.0 2.5 5.5 THE DATA STATEMENT INTEGER I, J REAL X(4) DATA I, J, X /1, 2, 1.5, 3.0, 2.5, 5.5/ Fill in the blank arrays:
A X 22 1.5 12 3.0 8 2.5 3 5.5 ARRAY REFERENCES A(2) = 17 A(I) = A(I) + 1 X(A(4)-1) = 7.7 + A(I+J) Fill in the blank arrays:
A X 22 1.5 17 3.0 8 2.5 3 5.5 ARRAY REFERENCES A(2) = 17 A(I) = A(I) + 1 X(A(4)-1) = 7.7 + A(I+J) Fill in the blank arrays:
A X 23 1.5 17 3.0 8 2.5 3 5.5 ARRAY REFERENCES A(2) = 17 A(I) = A(I) + 1 X(A(4)-1) = 7.7 + A(I+J) Fill in the blank arrays:
A X 23 1.5 17 3.0 8 2.5 3 5.5 ARRAY REFERENCES A(2) = 17 A(I) = A(I) + 1 X(A(4)-1) = 7.7 + A(I+J) Fill in the blank arrays:
A X 23 1.5 17 3.0 8 2.5 3 5.5 ARRAY REFERENCES A(2) = 17 A(I) = A(I) + 1 X(A(4)-1) = 7.7 + A(I+J) Fill in the blank arrays: X(A(4)-1)= X(3-1)= X(2)
A 23 17 8 3 ARRAY REFERENCES A(2) = 17 A(I) = A(I) + 1 X(A(4)-1) = 7.7 + A(I+J) Fill in the blank arrays: X 1.5 3.0 2.5 5.5
A 23 17 8 3 ARRAY REFERENCES A(2) = 17 A(I) = A(I) + 1 X(A(4)-1) = 7.7 + A(I+J) Fill in the blank arrays: X =7.7 + A(1+2) 1.5 =7.7 + A(3) 15.7 X(2) =7.7 + 8 2.5 5.5
D . … . … . ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays:
ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: D I . … . … .
D . … . … . ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: J I
ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: J D 1 I . … . … .
ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: J D 1 I . … . … .
D 1 . … . … . ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: J I
ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: J D 1 31 I . … . … .
ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: D 1 31 I . … . … .
ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: J D 1 31 61 1171 1141 . … . … .
ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: D 1 31 61 1141 1171 . … . … .
ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: D 1 31 61 1141 1171 . I … . … .
ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: D 1 31 61 1141 1171 . 1142 1172 2 32 62 I … . … .
ARRAY REFERENCES DO I = 1, 30 DO J = 1, 40 D(I,J) = I + (J-1)*30 ENDDO ENDDO Fill in the blank arrays: D 1 31 61 1141 1171 . 1142 1172 2 32 62 … . … 29 59 89 . 1169 1199 30 60 90 1170 1200
IMPLIED DO • A feature of READ, PRINT, and WRITE Syntax: (io_list, var=init, limit[,step]) • Examples PRINT *, (X(I), I = 1, 4) READ *, (X(I), I = 1, 4)
2.7 ARRAY I/O REAL X(4), Y(4,4) INTEGER I, J READ *, X READ *, X(1), X(2), X(3), X(4) READ *, (X(I), I = 1, 4) } Same X
2.7 6.1 ARRAY I/O REAL X(4), Y(4,4) INTEGER I, J READ *, X READ *, X(1), X(2), X(3), X(4) READ *, (X(I), I = 1, 4) } Same X
2.7 6.1 1.9 ARRAY I/O REAL X(4) INTEGER I, J, Y(4,4) READ *, X READ *, X(1), X(2), X(3), X(4) READ *, (X(I), I = 1, 4) } Same X
ARRAY I/O REAL X(4), Y(4,4) INTEGER I, J READ *, X READ *, X(1), X(2), X(3), X(4) READ *, (X(I), I = 1, 4) } Same X 2.7 6.1 1.9 9.3
ARRAY I/O } PRINT *, X PRINT *, X(1), X(2), X(3), X(4) PRINT *, (X(I), I = 1, 4) PRINT *, (X(I), I = 4, 1, -1) Same X 2.7 6.1 1.9 9.3
ARRAY I/O } PRINT *, X PRINT *, X(1), X(2), X(3), X(4) PRINT *, (X(I), I = 1, 4) PRINT *, (X(I), I = 4, 1, -1) Same X 2.7 6.1 1.9 9.3
ARRAY I/O } PRINT *, X PRINT *, X(1), X(2), X(3), X(4) PRINT *, (X(I), I = 1, 4) PRINT *, (X(I), I = 4, 1, -1) Same X 2.7 6.1 1.9 9.3
ARRAY I/O } PRINT *, X PRINT *, X(1), X(2), X(3), X(4) PRINT *, (X(I), I = 1, 4) PRINT *, (X(I), I = 4, 1, -1) Same X 9.3 1.9 6.1 2.7
1 2 3 4 ARRAY I/O } READ *, Y READ *, ((Y(I,J), I = 1, 4), J = 1, 4) READ *, ((Y(I,J), J = 1, 4), I = 1, 4) Same Y
ARRAY I/O } READ *, Y READ *, ((Y(I,J), I = 1, 4), J = 1, 4) READ *, ((Y(I,J), J = 1, 4), I = 1, 4) Same Y 1 5 2 6 3 7 4 8
ARRAY I/O } READ *, Y READ *, ((Y(I,J), I = 1, 4), J = 1, 4) READ *, ((Y(I,J), J = 1, 4), I = 1, 4) Same Y 1 5 9 2 6 10 3 7 11 4 8 12
ARRAY I/O } READ *, Y READ *, ((Y(I,J), I = 1, 4), J = 1, 4) READ *, ((Y(I,J), J = 1, 4), I = 1, 4) Same Y 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16
1 2 3 4 ARRAY I/O READ *, Y READ *, ((Y(I,J), I = 1, 4), J = 1, 4) READ *, ((Y(I,J), J = 1, 4), I = 1, 4) Y
ARRAY I/O READ *, Y READ *, ((Y(I,J), I = 1, 4), J = 1, 4) READ *, ((Y(I,J), J = 1, 4), I = 1, 4) Y 1 2 3 4 5 6 7 8
ARRAY I/O READ *, Y READ *, ((Y(I,J), I = 1, 4), J = 1, 4) READ *, ((Y(I,J), J = 1, 4), I = 1, 4) Y 1 2 3 4 5 6 7 8 9 11 12 10
ARRAY I/O READ *, Y READ *, ((Y(I,J), I = 1, 4), J = 1, 4) READ *, ((Y(I,J), J = 1, 4), I = 1, 4) Y 1 2 3 4 5 6 7 8 9 11 12 10 13 14 15 16