1 / 54

Chapter 7

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)

arch
Download Presentation

Chapter 7

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 7 ARRAYS

  2. 1 2 3 4 5 6 7 8 9 10 11 12 ARRAY DECLARATIONS • One Dimensional (Vector) INTEGER MONTH(12)

  3. 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)

  4. 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

  5. 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

  6. 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

  7. 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

  8. 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:

  9. 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:

  10. 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:

  11. 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:

  12. 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:

  13. 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:

  14. 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:

  15. 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:

  16. 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:

  17. 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:

  18. 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)

  19. 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

  20. 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

  21. 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:

  22. 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 . … . … .

  23. 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

  24. 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 . … . … .

  25. 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 . … . … .

  26. 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

  27. 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 . … . … .

  28. 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 . … . … .

  29. 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 . … . … .

  30. 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 . … . … .

  31. 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 … . … .

  32. 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 … . … .

  33. 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

  34. 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)

  35. 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

  36. 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

  37. 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

  38. 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

  39. 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

  40. 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

  41. 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

  42. 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

  43. 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

  44. 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

  45. 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

  46. 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

  47. 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

  48. 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

  49. 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

  50. 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

More Related