Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,180 --> 00:00:07,050
All right, so now that you know how to declare in, initialize a two dimensional array, you want to
2
00:00:07,050 --> 00:00:10,290
know how to access each of its elements.
3
00:00:10,560 --> 00:00:17,220
So to understand how it is done with a two dimensional array, we first need to recall how it was done
4
00:00:17,250 --> 00:00:19,530
with just one dimensional array.
5
00:00:19,590 --> 00:00:27,600
So suppose you had a one dimensional array that was defined as following into error of three elements
6
00:00:28,500 --> 00:00:33,330
in each of them equals two and the elements equal to one, two, three.
7
00:00:33,780 --> 00:00:41,280
So in this case, you should access any of the three elements within this array by just using the indexing
8
00:00:41,280 --> 00:00:46,060
thing that we've learned simply to access the first element of the array.
9
00:00:46,110 --> 00:00:55,080
We could just use a R at Index zero and to access the second element, we could use ARRL Index one and
10
00:00:55,080 --> 00:00:55,650
so on.
11
00:00:56,370 --> 00:01:06,060
We also do remember that a one dimensional array can be considered as just a row of elements and that
12
00:01:06,240 --> 00:01:14,430
a two dimensional array can be considered as a grid of rows and columns or just a bunch of rows.
13
00:01:15,030 --> 00:01:20,200
And if we said that a one dimensional array can be considered as just one row.
14
00:01:20,430 --> 00:01:27,990
So when we access some elements, we are some element within these array, as we did previously.
15
00:01:28,290 --> 00:01:31,980
We specify just the column number of these one row.
16
00:01:31,990 --> 00:01:37,270
So just like we you can see here on the screen with this little nice examples.
17
00:01:37,710 --> 00:01:47,010
So when we did our ARRL Index two, we told our computer to get the third element of this one dimensional
18
00:01:47,010 --> 00:01:52,320
array, meaning the value add of a third column of these array.
19
00:01:52,950 --> 00:02:00,960
Basically, as you probably guessed, when we want to access some element in the two dimensional array,
20
00:02:01,350 --> 00:02:09,360
we need to specify also the exact row, as well as the exact column that we want to access.
21
00:02:10,260 --> 00:02:15,520
And for example, let's say you had these following two dimensional array.
22
00:02:15,720 --> 00:02:23,370
So its name is Matt and it has two rows, three columns, and it's basically filled in the standard
23
00:02:23,370 --> 00:02:24,870
way of initializing.
24
00:02:25,590 --> 00:02:32,130
And we can basically hear or see the representation of these two dimensional array.
25
00:02:32,160 --> 00:02:42,270
And we can see that also we have the indexes for the rows and for the columns and it rows zero and column
26
00:02:42,270 --> 00:02:42,920
one.
27
00:02:42,960 --> 00:02:48,850
OK, or let's start with row zero and column zero here.
28
00:02:48,870 --> 00:02:51,630
Let's use this little nice laser.
29
00:02:51,630 --> 00:02:52,240
Come here.
30
00:02:52,260 --> 00:03:01,290
OK, so you have here this little nice lizarazo column zero and row zero, and it gives you the value
31
00:03:01,290 --> 00:03:02,190
of one.
32
00:03:02,190 --> 00:03:03,510
And also you can see.
33
00:03:03,990 --> 00:03:04,920
Let's move on.
34
00:03:05,160 --> 00:03:05,690
What are these.
35
00:03:05,700 --> 00:03:06,300
Oh, OK.
36
00:03:06,330 --> 00:03:11,070
So mad at row zero and column zero.
37
00:03:11,070 --> 00:03:12,710
Its value is one.
38
00:03:12,720 --> 00:03:16,920
So that's how we access this element in this array.
39
00:03:17,370 --> 00:03:23,070
And basically that's the whole point of how you access any of the elements in disarray.
40
00:03:23,100 --> 00:03:29,010
So Matt and the index are zero one it row zero.
41
00:03:29,160 --> 00:03:33,000
First of all, you specify the row and then you specify the column.
42
00:03:33,010 --> 00:03:35,250
So method zero zero.
43
00:03:35,250 --> 00:03:36,960
Index one zero zero.
44
00:03:36,960 --> 00:03:38,430
Index one, that's how you go.
45
00:03:38,650 --> 00:03:42,630
The values two, three, four or five, six doesn't really matter.
46
00:03:42,960 --> 00:03:51,150
So basically you can like to access each of these elements and to do whatever you like with them.
47
00:03:51,180 --> 00:03:59,340
So now let's see a couple of examples of how it will look like in code so and in the same way also can
48
00:03:59,340 --> 00:04:01,870
be done for any other of the elements.
49
00:04:01,890 --> 00:04:10,470
OK, so at row one and column two, you will simply go like row one column to change these value to
50
00:04:10,470 --> 00:04:11,150
twelve.
51
00:04:11,170 --> 00:04:12,150
And there you go.
52
00:04:12,150 --> 00:04:18,360
You axis the given element, modified its value and it was changed to twelve.
53
00:04:19,080 --> 00:04:26,310
And now basically that you know how to hexis each element and to change you directly, you can use it
54
00:04:26,310 --> 00:04:30,680
also to your advantage and simply print the value to the screen.
55
00:04:31,620 --> 00:04:38,970
Basically, you can print any of the elements of these two dimensional array using the printed function.
56
00:04:39,000 --> 00:04:40,080
So here it is.
57
00:04:40,090 --> 00:04:48,060
Are the changes that once you've executed each of these lines, the changes that were made inside of
58
00:04:48,060 --> 00:04:53,080
these two dimensional array, and also if you would like to access into print the value.
59
00:04:53,100 --> 00:04:55,360
So, first of all, you know how to access.
60
00:04:55,410 --> 00:04:59,880
There is no reason why you won't be able to print.
61
00:04:59,950 --> 00:05:04,210
These values, if you can access them, you can change them and you can print them.
62
00:05:04,870 --> 00:05:07,540
So this is it for these video guys.
63
00:05:08,080 --> 00:05:15,820
I think we've covered everything regarding the basics in the last two, three videos, the basics of
64
00:05:15,820 --> 00:05:17,140
the two dimensional arrays.
65
00:05:17,290 --> 00:05:24,520
It took us a little bit more than when I was planning to, but I decided to go like, you know, to
66
00:05:24,730 --> 00:05:31,930
to go with you step by step, because for some reason, a lot of students are struggling with this understanding
67
00:05:31,930 --> 00:05:35,890
of how to use the rows and the columns together.
68
00:05:35,920 --> 00:05:40,470
They know how to use for one dimensional array, but they find it.
69
00:05:40,900 --> 00:05:45,690
I don't know why they find it a little bit hard to work with two dimensional arrays.
70
00:05:45,910 --> 00:05:54,130
So I decided to give it some extra time and to talk about more, more in depth about the declaration,
71
00:05:54,130 --> 00:06:02,710
about the initialization, and also about how to access into print and to modify each of the two dimensional
72
00:06:02,800 --> 00:06:04,590
arrays values.
73
00:06:04,630 --> 00:06:06,510
So thank you for listening.
74
00:06:06,520 --> 00:06:11,670
Keep on practicing and I'll see you in the next video, as always.
75
00:06:12,730 --> 00:06:14,260
Have a nice day, guys.
76
00:06:14,300 --> 00:06:14,740
Goodbye.
7590
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.