All language subtitles for 2. Arrays - Copying an Array - Solution

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,360 --> 00:00:03,190 So let's understand how we can copy an array. 2 00:00:03,510 --> 00:00:09,090 So, first of all, we said that we need to initialize it with some values in the array is going to 3 00:00:09,090 --> 00:00:18,390 be of a size three, OK, because we represent a date and we know that it eight consists of day, month 4 00:00:18,390 --> 00:00:19,630 and year. 5 00:00:19,650 --> 00:00:23,430 So that's why we are going to use the size of three. 6 00:00:23,580 --> 00:00:27,150 And now what I want us to do is to initialize this array. 7 00:00:27,160 --> 00:00:32,140 So let's say we are going to call this array are indeed. 8 00:00:32,250 --> 00:00:37,420 OK, so in date will create, let's say, of cise right this size. 9 00:00:37,620 --> 00:00:43,230 So this way we declare an array of size three in this case sizes three. 10 00:00:43,470 --> 00:00:45,420 The name of this area is going to be date. 11 00:00:45,600 --> 00:00:51,450 And at every sale, at every element of this array, we will have an integer value. 12 00:00:51,460 --> 00:00:54,620 But we said that we don't want just to declare it. 13 00:00:54,630 --> 00:00:58,270 We said that we want to initialize it with some arbitrary value. 14 00:00:58,300 --> 00:01:04,930 So let's say one is the date is the day, two is the month and two thousand is the year. 15 00:01:04,950 --> 00:01:10,560 OK, so we initialized our array and now what do we want to do is to create additional arrays. 16 00:01:10,580 --> 00:01:14,190 So let's say into today two of the same size. 17 00:01:14,430 --> 00:01:18,930 We just created not two, not only initializing it, just creating it. 18 00:01:19,260 --> 00:01:26,400 And we want to copy we want to copy this array, the original array do these particular array, which 19 00:01:26,400 --> 00:01:28,290 is on initialized in this step. 20 00:01:28,650 --> 00:01:31,870 So what will be the most intuitive way to do so? 21 00:01:31,980 --> 00:01:37,830 So we are probably right, because the most easiest way that would come to mind is simply to use the 22 00:01:37,830 --> 00:01:42,570 assignment operation and just say day two equals today and that's it. 23 00:01:42,570 --> 00:01:43,230 You're done. 24 00:01:43,470 --> 00:01:48,960 And you expect that this array will just be copied into these data. 25 00:01:49,050 --> 00:01:50,450 But that's not the case. 26 00:01:50,460 --> 00:01:52,670 It won't work in our programming language. 27 00:01:52,920 --> 00:01:59,820 So for for copying an array, for copying one array into another, we are going to use some for a loop 28 00:02:00,300 --> 00:02:07,920 to basically these for a loop will allow us to run over each of these elements and to copy them one 29 00:02:07,920 --> 00:02:12,420 by one into these secondary our target array. 30 00:02:12,810 --> 00:02:18,840 So for that, we need to create additional variable int I that will help us in using the for loop and 31 00:02:18,840 --> 00:02:27,450 now we are going to use for equals to zero as long as I list this size I plus plus and now in the loop 32 00:02:27,450 --> 00:02:31,800 buddy, we are going to copy the elements one by one. 33 00:02:31,810 --> 00:02:36,150 So previously we have declared this array. 34 00:02:36,170 --> 00:02:37,970 So behind the scenes. 35 00:02:37,980 --> 00:02:46,650 OK, so we has three elements and there is some garbage values let's say are stored inside here. 36 00:02:46,890 --> 00:02:49,440 And we are going to iterate over this array. 37 00:02:49,440 --> 00:02:55,440 And first of all, IT index equals to zero, which will give us the value of one we are going to copy. 38 00:02:55,470 --> 00:03:01,170 So just use data and the indexing will be equals to date at the index. 39 00:03:01,590 --> 00:03:05,240 So copying element by element one after another. 40 00:03:05,430 --> 00:03:09,390 That's how you copy an array in C programming language. 41 00:03:09,460 --> 00:03:17,990 Now once you've copied, let's try to print the content of each of these arrays so it equals zero eyes 42 00:03:18,000 --> 00:03:20,730 list then size II plus plus. 43 00:03:21,240 --> 00:03:28,410 OK, so now we are going to print the values to print the elements inside of these of any of these arrays. 44 00:03:28,440 --> 00:03:40,410 So print f let's do it like this or print f r r let's see date original date original or Reiji original 45 00:03:40,920 --> 00:03:48,470 date and index the original date m original date. 46 00:03:48,480 --> 00:03:51,180 They know how we should do it, how we should do it. 47 00:03:51,300 --> 00:03:53,250 We should simply use some index. 48 00:03:53,260 --> 00:04:02,430 So let's say we are using original date at index, let's say percentage equals two percentage D and 49 00:04:02,670 --> 00:04:06,390 and here we are also going to use additional print earth line. 50 00:04:06,390 --> 00:04:09,630 So will we will see the target. 51 00:04:09,690 --> 00:04:15,960 OK, or that copied, copied, copied date at index percentages equals the percentage. 52 00:04:16,110 --> 00:04:22,530 And here instead of these percentages of the first one, we are going to specify are I right, which 53 00:04:22,530 --> 00:04:23,730 is the index. 54 00:04:24,000 --> 00:04:31,560 And here the value itself of the original date, which will be just date at the index I and here we 55 00:04:31,560 --> 00:04:33,180 are going to use pretty much the same. 56 00:04:33,190 --> 00:04:37,990 So I and just date to the date of the copy date index. 57 00:04:38,430 --> 00:04:45,510 OK, so what will be more correct probably is that we initiate or at first will just would have just 58 00:04:45,510 --> 00:04:52,500 created, created this array is the original date, will just name it original date and copy date. 59 00:04:52,500 --> 00:04:57,720 But we are already done with this exercise if we are going to run this program now. 60 00:04:57,900 --> 00:04:59,940 So build and run it, you're going. 61 00:05:00,000 --> 00:05:06,600 To see that original data, the index zero equals to one and also the copy dead, and also you can see 62 00:05:06,600 --> 00:05:09,570 the same values for each of these indexes. 63 00:05:09,960 --> 00:05:12,790 So this is how you copy an array. 64 00:05:12,990 --> 00:05:19,290 You don't use just the assignment operation like these, like data equals to date because that won't 65 00:05:19,290 --> 00:05:19,750 work. 66 00:05:20,970 --> 00:05:23,580 It probably won't even run to you guys. 67 00:05:24,300 --> 00:05:27,600 And my guess. 68 00:05:27,600 --> 00:05:29,290 Yeah, this is it for this video. 69 00:05:29,430 --> 00:05:36,660 Now you know how the copy how you can copy an array and it may be an array of integers, an array of 70 00:05:36,660 --> 00:05:39,690 floating points, an array of charges and so on. 71 00:05:40,020 --> 00:05:42,540 This is how you copy arrays. 7195

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.