This repository has been archived by the owner on Apr 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1006.html
40 lines (39 loc) · 5.21 KB
/
1006.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<span style="font-family: Courier New;">กำหนดให้ด้านทั้งหกของลูกเต๋ามีชื่อเรียกดังนี้คือ บน (Top), หน้า (Front), ซ้าย (Left), หลัง (Back), ขวา (Right) และ ล่าง (Bottom) และกำหนดให้ตำแหน่งเริ่มต้น ของลูกเต๋า มีแต้มแต่ละด้านเป็นดังนี้<br />
<br />
</span><center><span style="font-family: Courier New;"><img alt="" src="./img/1006/1006-1.gif" /><br />
<br />
</span></center><span style="font-family: Courier New;"> จากตำแหน่งนี้ลูกเต๋าสามารถหมุนได้หกทิศทาง คือ หมุนมาทางด้านหน้า (Forward) หมุนไปทางด้านหลัง (Backward) หมุนไปทางซ้าย (Left) หมุนไปทางขวา (Right) หมุนตามเข็มนาฬิกา (Clockwise) และหมุนทวนเข็มนาฬิกา (Counter clockwise) ซึ่งการหมุนเหล่านี้มีผลให้แต้มของลูกเต๋าแต่ละด้านเปลี่ยนไป ดังตารางต่อไปนี้<br />
<br />
</span><center><span style="font-family: Courier New;"><img alt="" src="./img/1006/1006-2.gif" /><br />
<br />
</span></center><span style="font-family: Courier New;"> จงเขียนโปรแกรมเพื่อรับจำนวนลูกเต๋า และสายอักขระแสดงทิศทางการหมุนของลูกเต๋า หาตำแหน่งสุดท้ายของลูกเต๋า และแสดงแต้มด้านหน้าของลูกเต๋าแต่ละลูก <b><br />
<br />
</b><u><b>ข้อมูลนำเข้า</b></u><br />
<strong>1.</strong> ข้อมูลนำเข้าบรรทัดแรกเป็นจำนวนลูกเต๋า มีค่าตั้งแต่ 1 ถึง 6 <br />
<strong>2.</strong> ข้อมูลแต่ละบรรทัดต่อมาเป็นสายอักขระแสดงทิศทางการหมุนของลูกเต๋าแต่ละลูก สายอักขระนี้มีความยาวตั้งแต่ 1 ถึง 1,000 ตัวอักษร อักขระแต่ละตัวเป็นอักษรภาษาอังกฤษตัวพิมพ์ใหญ่ตัวใดตัวหนึ่งในหกตัวคือ BCDFLR (ไม่มีตัวอักษรอื่นนอกจากนี้เลย) ซึ่งใช้แสดงทิศทางการหมุนของลูกเต๋าดังนี้ <br />
<br />
F - หมุนมาทางด้านหน้า (Forward) <br />
B - หมุนไปทางด้านหลัง (Backward) <br />
L - หมุนไปทางซ้าย (Left) <br />
R - หมุนไปทางขวา (Right) <br />
C - หมุนตามเข็มนาฬิกา (Clockwise) <br />
D - หมุนทวนเข็มนาฬิกา (Counter clockwise) <br />
<br />
กำหนดให้อักษรตัวแรกในสายอักขระเป็นการหมุนจาก “<strong>ตำแหน่งเริ่มต้น</strong>”, อักษรตัวที่สองเป็นการหมุนต่อจากที่กำหนดไว้ในอักษรตัวแรก ตัวอย่างเช่น สายอักขระ “CFRL” แทนการหมุนของลูกเต๋า โดยเริ่มจาก “ตำแหน่งเริ่มต้น” ลูกเต๋ามีการหมุนตามเข็มนาฬิกา จากนั้นจึงหมุนมาด้านหน้า แล้วหมุนไปทางขวา จากนั้นจึงหมุนมาทางซ้าย <b><br />
</b><u><b><br />
ข้อมูลส่งออก</b></u><br />
กำหนดให้การแสดงผลลัพธ์มีเพียงบรรทัดเดียว ได้แก่แต้มด้านหน้าของลูกเต๋า <strong>ในกรณีที่มีลูกเต๋ามากกว่า 1 ลูก</strong> ให้คั่นค่าแต่ละค่าด้วยเว้นวรรค 1 วรรค <b><br />
<br />
<u>ที่มา</u>: การแข่งขันคอมพิวเตอร์โอลิมปิก สอวน. ครั้งที่ 2 มหาวิทยาลัยบูรพา</b></span>
<table>
<tr>
<th>ข้อมูลนำเข้า</th>
<th>ข้อมูลส่งออก</th>
</tr>
<tr>
<td>3
<br />D
<br />FFBB
<br />BBFFR</td>
<td>3 2 2</td>
</tr></table>