テクノロジ系 2025年度 問8 ★★★☆☆ Medium
In the program below, the function subTotal receives an integer array inputarr as an argument, returns an array arr in which the sum of all elements of original array inputarr up to that location is stored in the same location. Which of the following is the correct combination of pieces of code to be inserted into [A] and [B] in the program? Here, the size of the array inputarr is greater than 1, elements outside the bounds of the array must not be accessed, and the array index starts at 1.
[Program]
O integer []:subTotal(integer []: inputarr)
integer: i
integer: n <- the number of elements in inputarr
integer []: arr <- {0, ..., 0} // Number of elements is n.
arr[1] <- inputarr[1]
for (increase i from [A] to n by 1)
arr[i] <- inputarr[i] + [B]
endfor
return arr
မြန်မာ
အောက်ပါ program တွင် subTotal function သည် ကိန်းပြည့် array inputarr ကို argument အဖြစ်လက်ခံကာ မူရင်း array inputarr ၏ ထိုနေရာအထိ ဒြပ်ဝင်အားလုံး၏ ပေါင်းလဒ်ကို တူညီသောနေရာတွင် သိမ်းဆည်းထားသော array arr ကို ပြန်ပေးသည်။ Program ထဲရှိ [A] နှင့် [B] တွင် ထည့်သွင်းရမည့် code ၏ မှန်ကန်သောပေါင်းစပ်မှုသည် အောက်ပါတို့အနက် အဘယ်နည်း? ဤနေရာတွင် inputarr ၏ အရွယ်အစားသည် 1 ထက်ကြီးပြီး array နယ်နိမိတ်အပြင်ဒြပ်ဝင်ကို access မပြုရ၊ array index သည် 1 မှစတင်သည်။
[Program]
O integer []:subTotal(integer []: inputarr)
integer: i
integer: n <- the number of elements in inputarr
integer []: arr <- {0, ..., 0} // Number of elements is n.
arr[1] <- inputarr[1]
for (increase i from [A] to n by 1)
arr[i] <- inputarr[i] + [B]
endfor
return arr
Correct answer: d — A: 2, B: arr[i-1]
English
arr[1] is set before the loop, so the loop starts at i=2. Each arr[i] is the cumulative sum: inputarr[i] + arr[i-1].
မြန်မာ
arr[1] ကို loop မစတင်မီသတ်မှတ်ထားပြီး loop သည် i=2 မှ စတင်သည်။ arr[i] တစ်ခုချင်းစီသည် ပြုစုပေါင်းလဒ်ဖြစ်သောကြောင့် inputarr[i] + arr[i-1] ဖြစ်သည်။
Study topic for this question
ဤမေးခွန်းအတွက် လေ့လာရန် ခေါင်းစဉ်
More questions on the same topic
တူညီသောခေါင်းစဉ်မှ မေးခွန်းများ
IP 2025 Q7 ★ IP 2025 Q58 ★★ IP 2025 Q60 ★★ IP 2025 Q61 ★★
data များစွာ သိမ်းဆည်းထားသော stack တစ်ခုမှ data ထုတ်ယူသောနည်းလမ်းမှာ အောက်ပါတို့အနက် အဘယ်နည်း?
IT လည်ပတ်မှု ထိရောက်မှုတိုးတက်စေပြီး ရရှိနိုင်မှုအပါအဝင် ဝန်ဆောင်မှုအရည်အသွေး မြင့်မားစေသောသင့်လျော်သောစီမံခန့်ခွဲမှုစနစ်သည် အောက်ပါတို့အနက် အဘယ်နည်း?
Incident စီမံခန့်ခွဲမှု၏ ရည်ရွယ်ချက်သည် အောက်ပါတို့အနက် အဘယ်နည်း?
အတွင်းပိုင်း system ၏ အသုံးပြုနည်းနှင့်ပတ်သက်သောမေးမြန်းမှုများအတွက် single point of contact ဖြစ်သော service desk ဆောက်လုပ်ရန် အသင့်တော်ဆုံးဌာနသည် အောက်ပါတို့အနက် အဘယ်နည်း?