The program has the following output:
1 2 3 4 5 6
1 3 6 10 15 21
1 2 6 24 120 720
See also the example of converting relative values into absolute values, and vice versa, on page 630.
Converting Absolute Values into Relative Values
OutputIterator
adjacent_difference (InputIterator sourceBeg, InputIterator sourceEnd,
OutputIterator destBeg)
OutputIterator
adjacent_difference (InputIterator sourceBeg, InputIterator sourceEnd,
OutputIterator destBeg, BinaryFunc op)
• The first form computes the difference of each element in the range [sourceBeg,sourceEnd) with
its predecessor and writes the result to the destination range starting with destBeg.
• The second form calls op for each element in the range [sourceBeg,sourceEnd) with its predecessor
and writes the result to the destination range starting with destBeg.
• The first element only is copied.
• Thus, for the values
a1 a2 a3 a4 ...
they compute and write either the values
a1, a2 - a1, a3 - a2, a4 - a3, ...
or the values
a1, a2 op a1, a3 op a2, a4 op a3, ...
respectively.
www.it-ebooks.info
โปรแกรมมีผลลัพธ์ต่อไปนี้:
1 2 3 4 5 6
1 3 6 10 15 21
1 2 6 24 120 720
ดูตัวอย่างของการแปลงค่าสัมพัทธ์เป็นค่าสัมบูรณ์ และในทางกลับกัน บนหน้า 630.
แปลงค่าเป็นค่าสัมพัทธ์
OutputIterator
adjacent_difference (InputIterator sourceBeg, InputIterator sourceEnd,
OutputIterator destBeg)
OutputIterator
adjacent_difference (InputIterator sourceBeg, InputIterator sourceEnd,
OutputIterator destBeg, BinaryFunc op)
•แบบแรกคำนวณความแตกต่างของแต่ละองค์ประกอบในช่วง [sourceBeg,sourceEnd) กับ
ของรุ่นก่อนและบันทึกผลลัพธ์ไปยังปลายทางช่วงเริ่มต้น ด้วย destBeg
•แบบที่สองเรียก op สำหรับแต่ละองค์ประกอบในช่วง [sourceBeg,sourceEnd) มีบรรพบุรุษ
และเขียนผลช่วงปลายเริ่มต้น ด้วย destBeg
•องค์ประกอบแรกเท่านั้นจะถูกคัดลอก
•ดังนี้ สำหรับค่า
a1 a2 a3 a4...
พวกเขาคำนวณ และเขียนแบบค่า
a1, a2 - a1, a3 - a4 - a3,... a2
หรือค่า
a1, a2 op a1, a3 op a2, a4 op a3,...
ตามลำดับ.
www.it-ebooks.info
การแปล กรุณารอสักครู่..

The program has the following output:
1 2 3 4 5 6
1 3 6 10 15 21
1 2 6 24 120 720
See also the example of converting relative values into absolute values, and vice versa, on page 630.
Converting Absolute Values into Relative Values
OutputIterator
adjacent_difference (InputIterator sourceBeg, InputIterator sourceEnd,
OutputIterator destBeg)
OutputIterator
adjacent_difference (InputIterator sourceBeg, InputIterator sourceEnd,
OutputIterator destBeg, BinaryFunc op)
• The first form computes the difference of each element in the range [sourceBeg,sourceEnd) with
its predecessor and writes the result to the destination range starting with destBeg.
• The second form calls op for each element in the range [sourceBeg,sourceEnd) with its predecessor
and writes the result to the destination range starting with destBeg.
• The first element only is copied.
• Thus, for the values
a1 a2 a3 a4 ...
they compute and write either the values
a1, a2 - a1, a3 - a2, a4 - a3, ...
or the values
a1, a2 op a1, a3 op a2, a4 op a3, ...
respectively.
www.it-ebooks.info
การแปล กรุณารอสักครู่..

โปรแกรมการส่งออกต่อไปนี้ :
1 2 3 4 5 6
1 3 5 10 15 20
1 2 6 24 120 720
เห็นตัวอย่างของการแปลงค่าเป็นค่าสัมพัทธ์สัมบูรณ์ และในทางกลับกัน ในหน้า 630 .
แปลงค่าเป็นญาติแน่นอนค่า
adjacent_difference ( inputiterator sourcebeg outputiterator , sourceend inputiterator , destbeg )
outputiterator outputiteratoradjacent_difference ( inputiterator sourcebeg inputiterator sourceend
, , outputiterator destbeg binaryfunc , OP )
- รูปแรกคำนวณความแตกต่างของแต่ละองค์ประกอบในช่วง sourcebeg sourceend ) [ ,
บรรพบุรุษของมันและเขียนผลปลายทางช่วงเริ่มต้นด้วย destbeg .
- แบบฟอร์มที่สองสาย OP สำหรับแต่ละองค์ประกอบในช่วง [ sourcebeg sourceend )
, บรรพบุรุษและเขียนผลปลายทางช่วงเริ่มต้นด้วย destbeg .
- องค์ประกอบแรกคือคัดลอก .
- ดังนั้นค่า
A1 A2 A3 A4 . . . . . . .
พวกเขาคำนวณและเขียนเหมือนกันค่า
A1 , A2 - A1 - A2 , A3 , A4 - A3 , . . . . . . .
A1 หรือค่า A1 , A2 และ A3 และ A2 , A4 และ A3 , . . . . . . .
www.it-ebooks.info ตามลำดับ
การแปล กรุณารอสักครู่..
