Ì䣱 ¡¡´Ø·¸¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë´Ø¤¹¤ë¼¡¤Îµ­½Ò¤òÆɤó¤Ç¡¤ÀßÌä 1 ¡Á 3 ¤ËÅú¤¨¤è¡£

¼¡¤Î¤è¤¦¤Ê¼õ¹ÖÀ¸É½¡¤¥¹¥¯¡¼¥ëɽ¡¤Ã϶èɽ¤«¤é¤Ê¤ë´Ø·¸¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬¤¢¤ë¡£Ã϶èÆâ¤Ë¤Ï¡¤Ê£¿ô¤Î¥¹¥¯¡¼¥ë¤¬¤¢¤ê¡¤³Æ¥¹¥¯¡¼¥ë¤ËÊ£¿ô¤Î¹ÖºÂ¤¬¤¢¤ë¡£¼õ¹ÖÀ¸¤Ï¡¤Ê£¿ô¤Î¹ÖºÂ¤ò¼õ¹Ö¤¹¤ë¤³¤È¤¬²Äǽ¤Ç¤¢¤ê¡¤°Û¤Ê¤Ã¤¿¥¹¥¯¡¼¥ë¤Î¹ÖºÂ¤ò¼õ¹Ö¤¹¤ë¾ì¹ç¤â¤¢¤ë¡£

¼õ¹ÖÀ¸É½

¼õ¹ÖÀ¸ÈÖ¹æ

¥¹¥¯¡¼¥ëÈÖ¹æ

¹ÖºÂ ID

¥¹¥¯¡¼¥ëɽ

¥¹¥¯¡¼¥ëÈÖ¹æ

¥¹¥¯¡¼¥ë̾

¹Ö»Õ¿ô

Ã϶襳¡¼¥É

Ã϶èɽ

Ã϶襳¡¼¥É

Ã϶è̾

ÀßÌ䣱¡¡¥¹¥¯¡¼¥ë¤´¤È¤Ë¼õ¹ÖÀ¸¿ô¤ò½¸·×¤·¤¿¡¤¥¹¥¯¡¼¥ëÊ̼õ¹Ö¾õ¶·É½¤ò¥Ó¥å¡¼¤È¤·¤Æºî¤ë¡£¤½¤Î¤¿¤á¤Î SQL ʸÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£¤³¤³¤Ç¡¤¼õ¹ÖÀ¸¿ô¤È¤Ï¡¤¼õ¹ÖÀ¸¤Î±ä¤Ù¿Í¿ô¤Ç¤¢¤ë¡£

¥¹¥¯¡¼¥ë̾

Ã϶è̾

¼õ¹ÖÀ¸¿ô

¹Ö»Õ¿ô

CREATE VIEW ¥¹¥¯¡¼¥ëÊ̼õ¹Ö¾õ¶·É½ (¥¹¥¯¡¼¥ë̾, Ã϶è̾, ¼õ¹ÖÀ¸¿ô, ¹Ö»Õ¿ô)
¡¡¡¡AS SELECT FROM ¼õ¹ÖÀ¸É½ J, ¥¹¥¯¡¼¥ëɽ S, Ã϶èɽ T
¡¡¡¡¡¡WHERE J.¥¹¥¯¡¼¥ëÈÖ¹æ = S.¥¹¥¯¡¼¥ëÈÖ¹æ AND S.Ã϶襳¡¼¥É = T.Ã϶襳¡¼¥É
¡¡¡¡¡¡GROUP BY

²òÅú·²

¥¢¡¡S.¥¹¥¯¡¼¥ë̾, T.Ã϶è̾, COUNT(J.¼õ¹ÖÀ¸ÈÖ¹æ), S.¹Ö»Õ¿ô

¥¤¡¡S.¥¹¥¯¡¼¥ë̾, T.Ã϶è̾, SUM(J.¼õ¹ÖÀ¸ÈÖ¹æ), S.¹Ö»Õ¿ô

¥¦¡¡S.¥¹¥¯¡¼¥ë̾, T.Ã϶襳¡¼¥É, S.¹Ö»Õ¿ô

¥¨¡¡S.¥¹¥¯¡¼¥ë̾, T.Ã϶è̾, S.¹Ö»Õ¿ô

¥ª¡¡S.¥¹¥¯¡¼¥ëÈÖ¹æ, T.Ã϶襳¡¼¥É, S.¹Ö»Õ¿ô

¥«¡¡S.¥¹¥¯¡¼¥ëÈÖ¹æ, T.Ã϶è̾, S.¹Ö»Õ¿ô


ÀßÌ䣲¡¡¥¹¥¯¡¼¥ëÊ̼õ¹Ö¾õ¶·É½¤Ï¡¤¼¡¤Î¤È¤ª¤ê¤È¤¹¤ë¡£

¡¡¥¹¥¯¡¼¥ëÊ̼õ¹Ö¾õ¶·É½

¥¹¥¯¡¼¥ë̾

Ã϶è̾

¼õ¹ÖÀ¸¿ô

¹Ö»Õ¿ô

Âè°ì¡¡

A

100

3

ÂèÆó¡¡

C

2,000

10

Âè»°¡¡

C

1,000

10

Âè»Í¡¡

B

200

3

Âè¸Þ¡¡

B

1,000

3

ÂèÏ»¡¡

B

300

3

Âè¼·¡¡

A

200

5

ÂèȬ¡¡

C

60

1

Âè¶å¡¡

D

20

1

Âè½½¡¡

D

15

1

Âè½½°ì

A

20

2

Âè½½Æó

B

10

3

¼¡¤Î SQL ʸ¤Î·ë²Ì¤Ï 1 ·ï¤Ç¤¢¤Ã¤¿¡£¤½¤Î¤È¤­¤Î SUM ( ¹Ö»Õ¿ô ) ¤ÎÃͤȤ·¤ÆÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£¤³¤³¤Ç¡¤SQL ʸ¤Î¶ç¤Ï¡¤FROM ¶ç¡¤WHERE ¶ç¡¤GROUP BY ¶ç¡¤HAVING ¶ç¡¤SELECT ¶ç¤Î½ç¤ËŬÍѤµ¤ì¤ë¡£

SELECT Ã϶è̾, SUM(¹Ö»Õ¿ô), COUNT(¥¹¥¯¡¼¥ë̾) FROM ¥¹¥¯¡¼¥ëÊ̼õ¹Ö¾õ¶·É½
¡¡¡¡WHERE ¹Ö»Õ¿ô < 5 GROUP BY Ã϶è̾ HAVING SUM(¹Ö»Õ¿ô) > 5

²òÅú·²

¥¢¡¡5¡¡¡¡¡¡¡¡¥¤¡¡11¡¡¡¡¡¡¡¡¥¦¡¡12¡¡¡¡¡¡¡¡¥¨¡¡14


ÀßÌ䣳¡¡¹Ö»Õ 1 ¿ÍÅö¤¿¤ê¤Î¼õ¹ÖÀ¸¿ô¤¬ 30 ¿Í̤Ëþ¤ÎÃ϶è¤ò¸¡º÷¤·¤¿¤¤¡£¼¡¤Î SQL ʸÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

¡¡¡¡SELECT Ã϶è̾ FROM ¥¹¥¯¡¼¥ëÊ̼õ¹Ö¾õ¶·É½ GROUP BY Ã϶è̾

²òÅú·²

¥¢¡¡HAVING AVG(¼õ¹ÖÀ¸¿ô/¹Ö»Õ¿ô) < 30

¥¤¡¡HAVING SUM(¼õ¹ÖÀ¸¿ô)/SUM(¹Ö»Õ¿ô) < 30

¥¦¡¡WHERE AVG(¼õ¹ÖÀ¸¿ô/¹Ö»Õ¿ô) < 30

¥¨¡¡WHERE SUM(¼õ¹ÖÀ¸¿ô)/SUM(¹Ö»Õ¿ô) < 30


Ì䣲 ¡¡ÄÌ¿®¥Í¥Ã¥È¥ï¡¼¥¯¤Ë´Ø¤¹¤ë¼¡¤Îµ­½Ò¤òÆɤó¤Ç¡¤ÀßÌ䣱¡¤£² ¤ËÅú¤¨¤è¡£

¥¢¥Ê¥í¥°¿®¹æ¤ò¥Ç¥£¥¸¥¿¥ë¿®¹æ¤ËÉä¹æ²½¤¹¤ëµ»½Ñ¤Ë¡¤¥Ñ¥ë¥¹Éä¹æÊÑÄ´Êý¼°¤¬¤¢¤ë¡£

¤³¤ÎÊÑÄ´Êý¼°¤Ç¤Ï¡¤¤Þ¤º¥¢¥Ê¥í¥°¿®¹æ¤ÎÇÈ·Á¤ò°ìÄê¤Î»þ´Ö´Ö³Ö¤Ç¼èÆÀ¤¹¤ë¡ÊɸËܲ½¡Ë¡£¼¡¤Ë¡¤É¸Ëܲ½¤·¤¿¥¢¥Ê¥í¥°Ãͤò¥Ç¥£¥¸¥¿¥ëÃͤËÊÑ´¹¡ÊÎ̻Ҳ½¡Ë¤·¡¤£²¿ÊÉä¹æ¤ËÃÖ¤­´¹¤¨¡ÊÉä¹æ²½¡Ë¡¤¤³¤ÎÉä¹æ²½¥Ó¥Ã¥ÈÎó¤ò¥Ç¥£¥¸¥¿¥ë¿®¹æ¤È¤·¤ÆÁ÷¿®¤¹¤ë¡£

¡¡É¸Ëܲ½¤Î»þ´Ö´Ö³Ö¤¬Ã»¤¯¡¤Éä¹æ²½¤Î¤±¤¿¿ô¤¬Â礭¤¤¤Û¤É¡¤ÉüÄ´»þ¤Ë¸µ¤Î¥¢¥Ê¥í¥°¿®¹æ¤ò¤è¤êÃé¼Â¤ËÉü¸µ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£

ÀßÌ䣱¡¡ÅÅÏò»À¼¤ò¥Ñ¥ë¥¹Éä¹æÊÑÄ´Êý¼°¤ÇÅÁÁ÷¤¹¤ë¡£¼¡¤Îµ­½ÒÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

ÅÅÏäβ»À¼ÂÓ°è¡Ê²»À¼¼þÇÈ¿ô¤ÎÈϰϡˤ¬ 0.3 ¡Á 3.4 kHz ¤Ç¤¢¤ë¤³¤È¤«¤é¡¤Í¾Íµ¤ò¤ß¤ÆºÇ¹â¼þÇÈ¿ô¤ò 4 kHz ¤È¤¹¤ë¡£É¸Ëܲ½ÄêÍý¡Ê¥·¥ã¥Î¥ó¤ÎÄêÍý¡Ë(1) ¤Ë¤è¤ë¤È¡¤ Hz °Ê¾å¤Î¼þÇÈ¿ô (1) ¤ÇɸËܲ½¤·¤ÆÅÁÁ÷¤¹¤ì¤Ð¤è¤¤¤³¤È¤Ë¤Ê¤ë¡£ Hz ¤ÇɸËܲ½¤¹¤ë¤È¤­¤Î»þ´Ö´Ö³Ö¤Ï¡¤ ÉäȤʤ롣°ì¤Ä¤ÎɸËܤÎÉä¹æ²½¤ËÍѤ¤¤ë¥Ó¥Ã¥È¿ô¤ò 8 ¥Ó¥Ã¥È¤È¤¹¤ë¤È¡¤ ¥Ó¥Ã¥È¡¿ÉäÎÅÁÁ÷®ÅÙ¤¬É¬ÍפȤʤ롣

Ãí (1)¡¡ÂоݤȤ¹¤ë¥¢¥Ê¥í¥°¿®¹æ¤ÎºÇ¹â¼þÇÈ¿ô¤ò f ¤È¤¹¤ë¤È¡¤ 2f °Ê¾å¤Î¼þÇÈ¿ô¤ÇɸËܲ½¤¹¤ì¤Ð¤è¤¤¡£¤¹¤Ê¤ï¤Á¡¤¼¡¼°¤Î´Ø·¸¤òËþ¤¿¤¹É¬Íפ¬¤¢¤ë¡£

¡¡¤³¤³¤Ç¡¤T ¤ÏɸËܲ½¤Î»þ´Ö´Ö³Ö¡ÊÉáˡ¤ f ¤ÏºÇ¹â¼þÇÈ¿ô¡ÊHz¡Ë

¡¡(2)¡¡£±ÉÃÅö¤¿¤ê¤ÎɸËܲ½¤Î²ó¿ô

a ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡4¡¡¡¡¡¡¡¡¥¤¡¡8¡¡¡¡¡¡¡¡¥¦¡¡16

¥¨¡¡4 k¡¡¡¡¡¡¡¡¥ª¡¡8 k¡¡¡¡¡¡¡¡¥«¡¡16 k

¥­¡¡4 M¡¡¡¡¡¡¡¡¥¯¡¡8 M¡¡¡¡¡¡¡¡¥±¡¡16 M

b ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡1.25 ¡ß 10¡Ý7 ¡¡¡¡¡¡¡¡¥¤¡¡2.5¡ß 10¡Ý7 ¡¡¡¡¡¡¡¡¥¦¡¡5.0¡ß 10¡Ý7

¥¨¡¡1.25 ¡ß 10¡Ý4 ¡¡¡¡¡¡¡¡¥ª¡¡2.5¡ß 10¡Ý4 ¡¡¡¡¡¡¡¡¥«¡¡5.0¡ß 10¡Ý4

¥­¡¡5.0 ¡ß 10¡Ý3 ¡¡¡¡¡¡¡¡¥¯¡¡2.5¡ß 10¡Ý2 ¡¡¡¡¡¡¡¡¥±¡¡1.25 ¡ß 10¡Ý1

c ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡32¡¡¡¡¡¡¡¡¥¤¡¡64¡¡¡¡¡¡¡¡¥¦¡¡128

¥¨¡¡32 k¡¡¡¡¡¡¡¡¥ª¡¡64 k¡¡¡¡¡¡¡¡¥«¡¡128 k

¥­¡¡32 M¡¡¡¡¡¡¡¡¥¯¡¡64 M¡¡¡¡¡¡¡¡¥±¡¡128 M


ÀßÌ䣲¡¡ÅÅÏäξì¹ç¡¤ÄÌÏ䴤ȤËÅÅÏòóÀþ¤òÍÑ°Õ¤·¤Æ¤¤¤Æ¤ÏÈñÍѤ¬¤«¤«¤ë¤Î¤Ç¡¤´ð´´¤ÎÅÁÁ÷Ï©¤Ç¤ÏÊ£¿ô¤Î²óÀþ¤ò«¤Í¤ÆÅÁÁ÷¤¹¤ë¡£¤³¤Î¤è¤¦¤Ë £±ËܤÎÅÁÁ÷Ï©¾å¤ËÊ£¿ô¤ÎÄÌ¿®²óÀþ¤ò«¤Í¤ë¤³¤È¤ò¿½Å²½¤È¤¤¤¦¡£¥Ç¥£¥¸¥¿¥ëÅÁÁ÷¤Î¿½Å²½Êý¼°¤È¤·¤Æ¡¤TDM¡Ê»þʬ³ä¿½Å²½¡ËÊý¼°¤¬¤¢¤ë¡£¤³¤ì¤Ï¡¤³Æ²óÀþ¤ËÂФ·¤Æ¡¤É¸Ëܲ½£±²óʬ¤ÎÉä¹æ²½¥Ó¥Ã¥ÈÎó¤òÁ÷¤ë»þ´Ö¤ò½çÈ֤˳ä¤êÅö¤Æ¤Æ¡¤Ê£¿ô²óÀþ¤Î¥Ç¥£¥¸¥¿¥ë¿®¹æ¤ò¤Þ¤È¤á¡Ê¥Õ¥ì¡¼¥à²½¡Ë¡¤£±ËܤÎÅÁÁ÷Ï©¾å¤Ë¥Õ¥ì¡¼¥à¤ò½çÈÖ¤ËÁ÷¤ê½Ð¤¹Êý¼°¤Ç¤¢¤ë¡£ÀßÌ䣱¡¡¤Î²»À¼ÅÁÁ÷¤ËÂФ·¤Æ¡¤30 ²óÀþ¤ò TDM Êý¼°¤Ë¤è¤Ã¤Æ¿½Å²½¤·¤ÆÅÁÁ÷¤¹¤ë¤È¤­¡¤É¬Í׺Ǿ®¸Â¤ÎÅÁÁ÷®ÅÙ¡Êk ¥Ó¥Ã¥È¡¿ÉáˤȤ·¤ÆÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

¡¡¤Ê¤ª¡¤1 ¥Õ¥ì¡¼¥à¤Ï¡¤30 ²óÀþ¤ÎɸËܲ½ 1 ²óʬ¤ÎÉä¹æ²½¥Ó¥Ã¥ÈÎó¡Ê³Æ£¸¥Ó¥Ã¥È¡Ë¤È¡¤¥Õ¥ì¡¼¥àƱ´ü¥Ñ¥ë¥¹ (3) ¤Ê¤É¤Î 16 ¥Ó¥Ã¥È¡Ê¿ÞÃæ¤Î S ¤È E ¤ò¹ç¤ï¤»¤¿Éôʬ¡Ë¤Ç¹½À®¤µ¤ì¤ë¡£

¡¡Ãí (3)¡¡Æ±´ü¤ò¤È¤ë¤¿¤á¤ËÉÕ¤±¤ëÀ©¸æÍѥӥåȥѥ¿¡¼¥ó

¿Þ¡¡¡¡1 ¥Õ¥ì¡¼¥à¤Î¹½À®¡ÊT¡§É¸Ëܲ½¤Î»þ´Ö´Ö³Ö¡Ë

²òÅú·²

¥¢¡¡720¡¡¡¡¡¡¡¡¥¤¡¡832¡¡¡¡¡¡¡¡¥¦¡¡1,088

¥¨¡¡1,792¡¡¡¡¡¡¡¡¥ª¡¡1,984¡¡¡¡¡¡¡¡¥«¡¡2,048

¥­¡¡3,712¡¡¡¡¡¡¡¡¥¯¡¡3,968¡¡¡¡¡¡¡¡¥±¡¡5,760


Ì䣳 ¡¡¥×¥í¥°¥é¥à¤Î¼Â¹Ô»þ´Ö¤Ë´Ø¤¹¤ë¼¡¤Îµ­½Ò¤òÆɤó¤Ç¡¤ÀßÌä¤ËÅú¤¨¤è¡£

½èÍý¤¹¤ë¥Ç¡¼¥¿Î̤ˤè¤Ã¤Æ¡¤¥×¥í¥°¥é¥à¤Î¼Â¹Ô»þ´Ö¤¬¤É¤Î¤è¤¦¤ËÊѲ½¤¹¤ë¤«¤ò¹Í¤¨¤ë¤È¤­¤Ë¡¤¥ª¡¼¥À¡Ê¤È¤¤¤¦³µÇ°¡Ë¤òÍѤ¤¤ë¡£Î㤨¤Ð¡¤ n ¸Ä¤Î¥Ç¡¼¥¿¤ò½èÍý¤¹¤ëºÇÂç¼Â¹Ô»þ´Ö¤¬ C n 2 ¡Ê C ¤ÏÄê¿ô¡Ë¤ÇÍÞ¤¨¤é¤ì¤ë¤È¤­¡¤¼Â¹Ô»þ´Ö¤Î¥ª¡¼¥À¤¬ n 2 ¤Ç¤¢¤ë¤È¤¤¤¦¡£

¡¡¡¡É½¡¡¥ª¡¼¥À¤ÎÎã

¼Â¹Ô»þ´Ö

¥ª¡¼¥À

C (Äê¿ô)

1

100 n

n

3 n 2 ¡Ü 5 n ¡Ü 1000

n 2

ÀßÌä¡¡¼¡¤Îµ­½ÒÃæ¤Î ¤ËÆþ¤ì¤ëŬÀÚ¤ÊÅú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£¤Ê¤ª¡¤²òÅú¤Ï½ÅÊ£¤·¤ÆÁª¤ó¤Ç¤â¤è¤¤¡£

¥×¥í¥°¥é¥à¤Î³Æ¹Ô¤Î¼Â¹Ô»þ´Ö¤¬°ìÄê¤Ç¤¢¤ê¡¤¤½¤Î»þ´Ö¤ò k ¤È¹Í¤¨¤ë¡Ê¹ÔÈÖ¹æ 5¡¤12¡¤14 ¤Ë¤Ä¤¤¤Æ¤â k ¤À¤±¤Î»þ´Ö¤òÍפ¹¡Ë¡£¤³¤Î¤È¤­¡¤¦ÁÉôʬ¤Î¼Â¹Ô»þ´Ö¤Ï ¤È¤Ê¤ë¤Î¤Ç¡¤¥ª¡¼¥À¤Ï ¤È¤Ê¤ë¡£ ¦ÂÉôʬ¤â¦ÁÉôʬ¤ÈƱÍͤ˷׻»¤·¡¤Î¾¼Ô¤Î¼Â¹Ô»þ´Ö¤ò­¤·¤Æ¤«¤é¥×¥í¥°¥é¥àÁ´ÂΤΥª¡¼¥À¤òµá¤á¤ë¤³¤È¤¬¤Ç¤­¤ë¡£¤·¤«¤·¡¤¼¡¤ÎÆó¤Ä¤Îµ¬Â§¤òÍѤ¤¤ë¤³¤È¤Ç¡¤¤è¤ê´Êñ¤Ë¥ª¡¼¥À¤òµá¤á¤ë¤³¤È¤¬²Äǽ¤È¤Ê¤ë¡£

µ¬Â§ 1¡§½ç¼¡½èÍý¤Ç¹½À®¤µ¤ì¤Æ¤¤¤ëÉôʬ¤Ï¡¤¼Â¹Ô»þ´Ö¤ÎºÇ¤âŤ¤¹Ô¤Î¥ª¡¼¥À¤¬¡¤Á´ÂΤμ¹Իþ´Ö¤Î¥ª¡¼¥À¤È¤Ê¤ë¡£

µ¬Â§ 2¡§·«ÊÖ¤·½èÍý¤Ç¹½À®¤µ¤ì¤Æ¤¤¤ëÉôʬ¤Ï¡¤·«¤êÊÖ¤µ¤ì¤ëÉôʬ¤Î¥ª¡¼¥À¤Ë·«ÊÖ¤·¿ô¤ò³Ý¤±¤¿ÃͤΥª¡¼¥À¡ÊÄê¿ô¤Ï̵»ë¤¹¤ë¡Ë¤¬¡¤Á´ÂΤμ¹Իþ´Ö¤Î¥ª¡¼¥À¤Ë¤Ê¤ë¡£
Î㤨¤Ð¡¤·«¤êÊÖ¤µ¤ì¤ëÉôʬ¤Î¥ª¡¼¥À¤¬ n 2 ¤Ç¡¤·«ÊÖ¤·¿ô¤¬ 100 n ¤Ê¤é¤Ð¡¤·«ÊÖ¤·½èÍýÁ´ÂΤΥª¡¼¥À¤Ï¡¤ n 3 ¤Ç¤¢¤ë¡£

¹ÔÈÖ¹æ 10 ¤È 11 ¤Î¼Â¹Ô»þ´Ö¤Î¥ª¡¼¥À¤Ï¡¤µ¬Â§ 1 ¤«¤é 1 ¤È¤Ê¤ë¡£¹ÔÈÖ¹æ 9 ¡Á 12 ¤Ï¹ÔÈÖ¹æ 10 ¤È 11 ¤ò n ²ó·«¤êÊÖ¤¹¤Î¤Ç¡¤¤³¤³¤Î¥ª¡¼¥À¤Ïµ¬Â§ 2 ¤«¤é ¤È¤Ê¤ë¡£Æ±Íͤ˹ͤ¨¤Æ¤¤¤¯¤È¡¤¦ÂÉôʬ¤Î¼Â¹Ô»þ´Ö¤Î¥ª¡¼¥À¤Ï ¤È¤Ê¤ë¡£

¤·¤¿¤¬¤Ã¤Æ¡¤¥×¥í¥°¥é¥àÁ´ÂΤμ¹Իþ´Ö¤Î¥ª¡¼¥À¤Ï ¤È¤Ê¤ë¡£

¡Ì¥×¥í¥°¥é¥à¡Í

¡Ê¹ÔÈÖ¹æ¡Ë

a ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡2 kn ¡Ü k ¡¡¡¡¡¡¡¡¥¤¡¡2 kn ¡Ü2 k ¡¡¡¡¡¡¡¡¥¦¡¡3 kn ¡Ü k

¥¨¡¡3 kn ¡Ü2 k ¡¡¡¡¡¡¡¡¥ª¡¡4 kn ¡Ü k ¡¡¡¡¡¡¡¡¥«¡¡4 kn ¡Ü2 k

b ¡Á e ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡log2 n ¡¡¡¡¡¡¡¡¥¤¡¡ n ¡¡¡¡¡¡¡¡¥¦¡¡ n log2 n

¥¨¡¡ n 2 ¡¡¡¡¡¡¡¡¥ª¡¡ n 3


Ì䣴 ¡¡¼¡¤Î¥×¥í¥°¥é¥à¤ÎÀâÌÀµÚ¤Ó¥×¥í¥°¥é¥à¤òÆɤó¤Ç¡¤ÀßÌä¤ËÅú¤¨¤è¡£

¡Ì¥×¥í¥°¥é¥à¤ÎÀâÌÀ¡Í½ÐȯÃϤ«¤éÌÜŪÃϤޤǤκÇû·ÐÏ©¤òµá¤á¤ëÉû¥×¥í¥°¥é¥à¤Ç¤¢¤ë¡£

(1)¡¡Éû¥×¥í¥°¥é¥à SP ¤Ï¡¤N ¸Ä¡ÊN ¡ä £±¡Ë¤ÎÃÏÅÀ¤Ç¹½À®¤µ¤ì¤ë¿Þ£±¤Î¤è¤¦¤ÊÍ­¸þ¥°¥é¥Õ¤Çɽ¤µ¤ì¤ë·ÐÏ©¿Þ¤Ë¤ª¤¤¤Æ¡¤ÃÏÅÀ£±¡Ê½ÐȯÃϡˤ«¤éÃÏÅÀ N¡ÊÌÜŪÃϡˤޤǤκÇû·ÐÏ©¤òµá¤á¤Æ¡¤½ÐÎϤ¹¤ë¥×¥í¥°¥é¥à¤Ç¤¢¤ë¡£¤Ê¤ª¡¤¿Þ£±¤Ë¤ª¤¤¤Æ¡¤±ß¤ÏÃÏÅÀ¤ò¡¤Ìð°õ¤Î¸þ¤­¤Ï¿Ê¹ÔÊý¸þ¤ò¡¤Ìð°õ¤ËÉÕ¤±¤¿¿ô»ú¤ÏÃÏÅÀ´Ö¤Îµ÷Î¥¤òɽ¤¹¡£

(2)¡¡¤³¤ÎÉû¥×¥í¥°¥é¥à¤Ç¤Ï¡¤¼¡¤ÎÇÛÎó¤òÍѤ¤¤ë¡£Í×ÁÇÈÖ¹æ i¡¤j ¤ÎÃÍ¤Ï 1¡¤2¡¤¡Ä¡¤N ¤Ç¤¢¤ê¡¤³ÆÃÏÅÀ¤ÈÂбþ¤·¤Æ¤¤¤ë¡£

C[i, j]¡§ ÃÏÅÀ i ¤«¤éÃÏÅÀ j ¤Þ¤Ç¤Îµ÷Î¥¤òɽ¤¹ÇÛÎó¤Ç¤¢¤ë¡£ÃÏÅÀ i ¤«¤éÃÏÅÀ j ¤Þ¤Ç¤ÎľÀܤηÐÏ©¤¬¤Ê¤¤¾ì¹ç¡¤ÃÏÅÀ i ¤ÈÃÏÅÀ j ¤¬Åù¤·¤¤¾ì¹ç¡¤µÚ¤Ó¿Ê¹ÔÊý¸þ¤ÈµÕ¤Î¾ì¹ç¤Ï ¡ç ¤¬³ÊǼ¤µ¤ì¤Æ¤¤¤ë¡£
Î㤨¤Ð¿Þ£± ¤Ç¤Ï¡¤C[1, 2] ¡á 30¡¤C[1, 3] ¡á ¡ç¡¤C[2, 1] ¡á ¡ç¡¤C[2, 2] ¡á ¡ç ¤Ç¤¢¤ë¡£
D[i]¡§ ÃÏÅÀ£± ¤«¤éÃÏÅÀ i ¤Þ¤Ç¤ÎºÇûµ÷Î¥¤ò³ÊǼ¤¹¤ë¤¿¤á¤ÎÇÛÎó¤Ç¤¢¤ë¡£½é´üÀßÄê¤ÇÃÏÅÀ£± ¤«¤éÃÏÅÀ i ¤Þ¤Ç¤Îµ÷Î¥ C[1, i] ¤òÀßÄꤹ¤ë¡£Î㤨¤Ð¿Þ£± ¤Î¾ì¹ç¤Î½é´üÀßÄê¤Ç¤Ï¡¤D[2] ¡á C[1, 2] ¡á 30¡¤D[3]¡á C[1, 3] ¡á ¡ç¡¤ D[4] ¡á C[1, 4] ¡á 20¡¤D[5] ¡á C[1, 5] ¡á 120 ¤¬ÀßÄꤵ¤ì¤ë¡£
P[i]¡§ ºÇû·ÐÏ©¤òµá¤á¤ë²áÄø¤Ç¡¤½èÍýºÑ¤È¤Ê¤Ã¤¿ÃÏÅÀ¤ò¼±Ê̤¹¤ë¤¿¤á¤ÎÇÛÎó¤Ç¤¢¤ë¡£½é´üÀßÄê¤Ç¤Ï P[1] ¤À¤±¤Ë 1 ¤òÀßÄꤷ¡¤Â¾¤Î¤¹¤Ù¤Æ¤ÎÍ×ÁÇ¤Ë¤Ï 0 ¤òÀßÄꤹ¤ë¡£ºÇû·ÐÏ©¤òµá¤á¤¿¸å¤Ï¤¹¤Ù¤Æ¤ÎÍ×ÁǤ¬ 1 ¤È¤Ê¤ë¡£
S[i]¡§ ÃÏÅÀ 1 ¤«¤éÃÏÅÀ i ¤Þ¤Ç¤ÎºÇû·ÐÏ©¤òµá¤á¤ë²áÄø¤Ç¡¤ÃÏÅÀ i ¤ÎľÁ°¤ÎÃÏÅÀ¤ò³ÊǼ¤¹¤ë¤¿¤á¤ÎÇÛÎó¤Ç¤¢¤ë¡£½é´üÀßÄê¤Ç¤Ï¤¹¤Ù¤Æ¤ÎÍ×ÁÇ¤Ë 1 ¤òÀßÄꤹ¤ë¡£Î㤨¤Ð¿Þ£± ¤Î¾ì¹ç¡¤ºÇû·ÐÏ©¤òµá¤á¤¿¸å¤Ï S[2] ¡á 1¡¤S[3] ¡á 4¡¤S[4] ¡á 1¡¤S[5] ¡á 3 ¤È¤Ê¤ê¡¤ÃÏÅÀ 5 ¤ÎľÁ°¤ÏÃÏÅÀ 3¡¤ÃÏÅÀ 3 ¤ÎľÁ°¤ÏÃÏÅÀ 4¡¤ÃÏÅÀ¡£
W[i]¡§ S[i] ¤òÍѤ¤¤ÆºÇû·ÐÏ©¤ò½ÐÎϤ¹¤ëºÝ¤Ë»ÈÍѤ¹¤ëºî¶ÈÍѤÎÇÛÎó¤Ç¤¢¤ë¡£

(3)¡¡ºÇû·ÐÏ©¤òµá¤á¤ë¼ê½ç¤Ï¡¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

­¡¡¡½èÍý¤·¤Æ¤¤¤Ê¤¤¤¹¤Ù¤Æ¤ÎÃÏÅÀ¡ÊP[i] ¡á 0¡Ë¤Î¤¦¤Á¤Ç¡¤D[T] ¤¬ºÇ¾®¤Ç¤¢¤ëÃÏÅÀ T ¤òÁª¤Ö¡£

­¢¡¡ÃÏÅÀ T ¤ò½èÍýºÑ¡ÊP[T] ¡á 1¡Ë¤È¤¹¤ë¡£

­£¡¡½èÍý¤·¤Æ¤¤¤Ê¤¤¤¹¤Ù¤Æ¤ÎÃÏÅÀ¡ÊP[i] ¡á 0¡Ë¤ËÂФ·¤Æ¡¤D[T] ¡Ü C[T, i] ¤ÎÃͤ¬ D[i] ¤ÎÃͤè¤ê¾®¤µ¤±¤ì¤Ð¡¤D[T] ¡Ü C[T, i] ¤ÎÃÍ¤Ç D[i] ¤òÃÖ¤­´¹¤¨¤ë¡£

­¤¡¡­£¤Ç D[i] ¤òÃÖ¤­´¹¤¨¤¿¾ì¹ç¡¤S[i] ¤Ë T ¤òÂåÆþ¤¹¤ë¡£

­¥¡¡½èÍý ­¡ ¡Á ­¤ ¤ò¡¤Á´ÃÏÅÀ¤¬½èÍýºÑ¤Ë¤Ê¤ë¤Þ¤Ç·«¤êÊÖ¤¹¡£

(4)¡¡ºÇû·ÐÏ©¤òµá¤á¤¿¸å¡¤ÇÛÎó S ¤òÍѤ¤¤ÆºÇû·ÐÏ©¤ò½ÐÎϤ¹¤ë¡£½ÐÎϤˤϡ¤¿ôÃÍ X ¤ò½ÐÎϤ·¤¿¸å¤Ë²þ¹Ô¤¹¤ëÉû¥×¥í¥°¥é¥à Output(X) ¤òÍøÍѤ¹¤ë¡£

(5)¡¡¿Þ£± ¤Î·ÐÏ©¿Þ¤ËÂФ¹¤ë½ÐÎÏ·ë²Ì¤ò¿Þ£² ¤Ë¡¤¤Þ¤¿ºÇû·ÐÏ©¤òµá¤á¤ë²áÄø¤Ç¤ÎÇÛÎó¤ÈÊÑ¿ô T ¤ÎÃͤÎÊѲ½¤òɽ£± ¤Ë¼¨¤¹¡£

(6)¡¡½ÐȯÃϤ«¤éÌÜŪÃϤޤǤηÐÏ©¤Ï¡¤É¬¤ºÂ¸ºß¤¹¤ë¤â¤Î¤È¤¹¤ë¡£


¿Þ£±¡¡·ÐÏ©¿Þ¤ÎÎã¡ÊN ¡á 5 ¤Î¾ì¹ç¡Ë

1¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ 
4¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ 
3¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ 
5¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ 

¿Þ£²¡¡¿Þ£±¤Î·ÐÏ©¿Þ¤ËÂФ¹¤ë½ÐÎÏ·ë²Ì

¡¡¡¡¡¡É½£±¡¡¿Þ£±¤ÎºÇû·ÐÏ©¤òµá¤á¤ë²áÄø¤ÎÇÛÎó¤ÈÊÑ¿ô T ¤ÎÃͤÎÊѲ½

(7)¡¡Éû¥×¥í¥°¥é¥à SP ¤Î°ú¿ô¤Ï¡¤É½ 2 ¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

¡¡¡¡¡¡¡¡¡¡¡¡É½£²¡¡SP ¤Î°ú¿ô

ÊÑ¿ô̾

ÆþÎÏ¡¿½ÐÎÏ

°Õ¡¡¡¡Ì£

N

ÆþÎÏ

ÃÏÅÀ¿ô

C[,]

ÆþÎÏ

ÃÏÅÀ´Ö¤Îµ÷Î¥¤òɽ¤¹ 2 ¼¡¸µ¤ÎÄê¿ôÇÛÎó

¡Ì¥×¥í¥°¥é¥à¡Í

ÀßÌä¡¡¥×¥í¥°¥é¥àÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

a ¡Á c ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡P[Y] ¢« 0¡¡¡¡¡¡¡¡¥¤¡¡P[Y] ¢« 1¡¡¡¡¡¡¡¡¥¦¡¡S[T] ¢« Y

¥¨¡¡S[Y] ¢« T¡¡¡¡¡¡¡¡¥ª¡¡Y ¢« S[X]¡¡¡¡¡¡¡¡¥«¡¡Y ¢« S[Y]

¥­¡¡Z ¢« D[Y]

d ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡X ¡ä 0¡¡¡¡¡¡¡¡¥¤¡¡X ¡æ 0¡¡¡¡¡¡¡¡¥¦¡¡W[X] ¡ä 0¡¡¡¡¡¡¡¡¥¨¡¡W[X] ¡æ 0


Ì䣵 ¡¡¥×¥í¥°¥é¥àÀ߷פ˴ؤ¹¤ë¼¡¤Îµ­½Ò¤òÆɤó¤Ç¡¤ÀßÌä 1¡¤2 ¤ËÅú¤¨¤è¡£

³ÆŹÊÞ¤¬ËèÆü¤Î±Ä¶È»þ´Ö½ªÎ»¸å¤ËËܼҤØÁ÷¤Ã¤Æ¤¯¤ë¾¦Éʤκ߸˾ðÊó¤È¡¤¤½¤ÎŹÊޤˤª¤±¤ë²áµî¤ÎÈÎÇä¼ÂÀӤξðÊ󤫤顤¾¦ÉʤÎÊä½¼¤Î¤¿¤á¤ÎÇÛÁ÷¾ðÊó¤òºîÀ®¤¹¤ë¥×¥í¥°¥é¥à¤òÀ߷פ¹¤ë¡£¤³¤Î¥×¥í¥°¥é¥à¤Î³µÍפϡ¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

¡Ì¥×¥í¥°¥é¥à¤Î³µÍסÍ

(1)¡¡³ÆŹÊÞ¤¬Á÷¤Ã¤Æ¤¯¤ë¾¦Éʤκ߸˾ðÊó¤ÎÍͼ°¤ò¼¡¤Ë¼¨¤¹¡£¤³¤³¤Ë³ÊǼ¤µ¤ì¤¿Ç¯·îÆü¤ÎÍâ±Ä¶ÈÆü¤¬¡¤ÇÛÁ÷¾ðÊó¤òºîÀ®¤¹¤ëÂоݤȤʤëÆü¡ÊÇÛÁ÷ÂоÝÆü¤È¸Æ¤Ö¡Ë¤È¤Ê¤ë¡£

ǯ

·î

Æü

ŹÊÞ¥³¡¼¥É

¾¦ÉÊ¥³¡¼¥É

ºß¸ËÎÌ

(2)¡¡³ÆŹÊޤˤª¤±¤ë³Æ¾¦Éʤβáµî¤ÎÈÎÇäÎ̤ϡ¤ÈÎÇä¼ÂÀÓ¥Õ¥¡¥¤¥ë¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ë¡£ÈÎÇä¼ÂÀÓ¥Õ¥¡¥¤¥ë¤ÎÍͼ°¤ò¼¡¤Ë¼¨¤¹¡£

ǯ

·î

Æü

ŹÊÞ¥³¡¼¥É

¾¦ÉÊ¥³¡¼¥É

ÈÎÇäÎÌ

(3)¡¡ÈÎÇä¼ÂÀÓ¥Õ¥¡¥¤¥ë¤Î²áµî¤ÎÈÎÇäÎ̤ò»ÈÍѤ·¤Æ¡¤ÇÛÁ÷ÂоÝÆü¤ÎÈÎÇäͽ¬Î̤òµá¤á¤ë¡£

(4)¡¡ÈÎÇäͽ¬Î̤Π1.2 Çܤò¡¤ºß¸Ë¤È¤·¤ÆɬÍפÊÎ̤Ȥ¹¤ë¡£ºß¸ËÎ̤¬¤³¤ÎÎ̤ËËþ¤¿¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¤¤½¤Îº¹¤òÉÔ­Î̤Ȥ¹¤ë¡£

(5)¡¡¾¦Éʤϡ¤È¢¤Ë¤³¤óÊñ¤µ¤ì¤Æ¤¤¤ë¡£¾¦Éʤˤè¤Ã¤Æ¤³¤óÊñ¤¹¤ëÈ¢¤Î¼ïÎब°Û¤Ê¤ê¡¤È¢¤ËÆþ¤ë¾¦ÉʤθĿô¤â°Û¤Ê¤ë¡£È¢¤Î¼ïÎà¤ò¼¨¤¹¶èʬ¡ÊÈ¢¶èʬ¤È¸Æ¤Ö¡ËµÚ¤Ó¤½¤ÎÈ¢¤ËÆþ¤ë¾¦ÉʤθĿô¡Ê¤³¤óÊñ¿ô¤È¸Æ¤Ö¡Ë¤Ï¡¤¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¾¦ÉÊɽ¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ë¡£¾¦ÉÊɽ¤ÎÍͼ°¤ò¼¡¤Ë¼¨¤¹¡£²¼Àþ¤òÉÕ¤±¤¿¹àÌܤϼ祭¡¼¤Ç¤¢¤ë¡£

¾¦ÉÊ¥³¡¼¥É

¾¦ÉÊ̾

È¢¶èʬ

¤³¤óÊñ¿ô

¤½¤Î¾¤Î¾ðÊó

(6)¡¡ÇÛÁ÷¤¹¤ë¾¦ÉʤθĿô¤¬ÉÔ­Ḭ̂ʾå¤Ë¤Ê¤ë¤è¤¦¤ËÈ¢¤Î¸Ä¿ô¡ÊÇÛÁ÷È¢¿ô¤È¸Æ¤Ö¡Ë¤ò»»½Ð¤·¡¤Å¹ÊÞÊÌ¡¦¾¦ÉÊÊ̤ÎÇÛÁ÷¾ðÊó¤òºîÀ®¤·¤Æ½ÐÎϤ¹¤ë¡£ÇÛÁ÷¾ðÊó¤ÎÍͼ°¤ò¼¡¤Ë¼¨¤¹¡£

ǯ

·î

Æü

ŹÊÞ¥³¡¼¥É

¾¦ÉÊ¥³¡¼¥É

ÇÛÁ÷È¢¿ô

ÀßÌ䣱¡¡¥×¥í¥°¥é¥à¤Î¼ç½èÍý¤ò»Í¤Ä¤Î¥â¥¸¥å¡¼¥ë¤Ëʬ³ä¤·¡¤¥×¥í¥°¥é¥à¹½Â¤¿Þ¡Ê¿Þ£±¡ËµÚ¤Ó¥â¥¸¥å¡¼¥ë´Ö¤Î¥Ç¡¼¥¿¤Î´ØÏ¢¤ò¼¨¤¹¥Ç¡¼¥¿Î®¤ì¿Þ¡Ê¿Þ£²¡Ë¤òºîÀ®¤·¤¿¡£¿Þ£± µÚ¤Ó¿Þ£² Ãæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

¿Þ£±¡¡¥×¥í¥°¥é¥à¹½Â¤¿Þ

¿Þ£²¡¡¥Ç¡¼¥¿Î®¤ì¿Þ

²òÅú·²

¥¢¡¡¤³¤óÊñ¿ô¡¡¡¡¡¡¡¡¡¡¡¡¡¡¥¤¡¡ºß¸ËÎÌ¡¡¡¡¡¡¡¡¡¡¡¡¥¦¡¡¾¦ÉÊ¥³¡¼¥É

¥¨¡¡¾¦ÉÊɽ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¥ª¡¡Å¹ÊÞ¥³¡¼¥É¡¡¡¡¡¡¡¡¥«¡¡ÇÛÁ÷È¢¿ô

¥­¡¡ÈÎÇä¼ÂÀÓ¥Õ¥¡¥¤¥ë¡¡¡¡¡¡¥¯¡¡ÈÎÇäͽ¬ÎÌ¡¡¡¡¡¡¡¡¥±¡¡ÈÎÇäÎÌ

¥³¡¡ÉÔ­ÎÌ


ÀßÌ䣲¡¡¥×¥í¥°¥é¥à¤Î±¿ÍѤò³«»Ï¤·¤Æ¤·¤Ð¤é¤¯¤¿¤Ä¤È¡¤ºß¸Ë¾ðÊó¤Ë´Þ¤Þ¤ì¤ë¾¦ÉʤËÂбþ¤¹¤ëÈÎÇä¼ÂÀÓ¤¬¡¤ÈÎÇä¼ÂÀÓ¥Õ¥¡¥¤¥ë¤Ë¸«¤Ä¤«¤é¤Ê¤¤¤³¤È¤¬Â¿¤¯¤Ê¤Ã¤¿¡£¤³¤ì¤Ï¡¤²áµî¤ÎÈÎÇä¼ÂÀӤΤʤ¤¿·µ¬¾¦Éʤ¬Áý¤¨¤¿¤³¤È¤¬¸¶°ø¤Ç¤¢¤ë¡£¤½¤³¤Ç¡¤ºß¸Ë¾ðÊóÃæ¤Î¾¦Éʤȡ¤¤³¤ì¤ËÎà»÷¤·²áµî¤ËÈÎÇä¼ÂÀӤΤ¢¤ë¾¦ÉÊ¡ÊÎà»÷¾¦ÉʤȸƤ֡ˤò´ØÏ¢ÉÕ¤±¤ë¤³¤È¤Ë¤·¤¿¡£¤³¤Î¤¿¤á¡¤¼¡¤Ë¼¨¤¹¾¦ÉÊÂбþɽ¤ò¿·¤¿¤ËºîÀ®¤·¡¤¤³¤Îɽ¤ò»È¤Ã¤Æ½èÍý¤ò¹Ô¤¦¤è¤¦¤Ë¥×¥í¥°¥é¥à¤ò½¤Àµ¤¹¤ëÊý¿Ë¤òΩ¤Æ¤¿¡£²¼Àþ¤òÉÕ¤±¤¿¹àÌܤϼ祭¡¼¤Ç¤¢¤ë¡£

¾¦ÉÊ¥³¡¼¥É

Îà»÷¾¦ÉʤÎ
¾¦ÉÊ¥³¡¼¥É

¾¦ÉÊÂбþɽ¤Î¥Ç¡¼¥¿¤òÆþÎϤ¹¤ë¥â¥¸¥å¡¼¥ë¤È¤·¤ÆÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

²òÅú·²

¥¢¡¡ºß¸Ë¾ðÊó¤Î¼õ¿®¡¡¡¡¡¡¡¡¡¡¥¤¡¡ÇÛÁ÷È¢¿ô¤Î»»½Ð

¥¦¡¡ÈÎÇäͽ¬Î̤λ»½Ð¡¡¡¡¡¡¡¡¥¨¡¡ÉÔ­Î̤λ»½Ð


Ì䣶 ¡¡¼¡¤Î C ¥×¥í¥°¥é¥à¤ÎÀâÌÀµÚ¤Ó¥×¥í¥°¥é¥à¤òÆɤó¤Ç¡¤ÀßÌä¤ËÅú¤¨¤è¡£

¡Ì¥×¥í¥°¥é¥à¤ÎÀâÌÀ¡Í

¥³¥ó¥µ¡¼¥È²ñ¾ì¤Ë¤ª¤¤¤Æ¡¤Ï¢Â³¤·¤Æ³ÎÊݤ·¤¿¤¤ÀÊ¿ô¤òÍ¿¤¨¤é¤ì¤ë¤È¡¤ºÂÀʤò·èÄꤷ¡¤·ë²Ì¤òÊÖµÑÃͤȤ·¤ÆÊÖ¤¹¥×¥í¥°¥é¥à¤Ç¤¢¤ë¡£

(1)¡¡¥³¥ó¥µ¡¼¥È²ñ¾ì¤ÎºÂÀʤϡ¤¿Þ¤Ë¼¨¤¹¤È¤ª¤ê¤Ç¤¢¤ë¡£

¿Þ¡¡¥³¥ó¥µ¡¼¥È²ñ¾ì¤ÎºÂÀÊÇÛÃÖ

­¡¡¡ºÂÀʤϡ¤A ¡Á Z ¤Î 26 Î󤫤é¤Ê¤ê¡¤Îó¤Ë¤è¤Ã¤ÆºÂÀÊ¿ô¤¬°Û¤Ê¤ë¡£³ÆÎó¤ÎºÂÀÊ¿ô¤Ï¡¤Îó A ¡Á Z ¤Î½ç¤ËÂç°è¤ÎÇÛÎó cnum ¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ë¡£

­¢¡¡ºÂÀÊÈÖ¹æ¤Ï¡¤Îó¤ÈÈÖ¤«¤é¤Ê¤ë¡£È֤Ȥϡ¤³ÆÎó¤Ë¤Ä¤¤¤Æ¥¹¥Æ¡¼¥¸¤Ë¸þ¤«¤Ã¤Æº¸¤«¤é²¿ÈÖÌܤκÂÀʤǤ¢¤ë¤«¤ò¼¨¤¹ÈÖ¹æ¤Î¤³¤È¤Ç¤¢¤ë¡£Î㤨¤Ð¡¤¡ÈL Îó 6 È֡ɤκÂÀʤȤϡ¤¥¹¥Æ¡¼¥¸¤«¤é 12 ÎóÌÜ¡ÊL Îó¡Ë¤Î¥¹¥Æ¡¼¥¸¤Ë¸þ¤«¤Ã¤Æº¸¤«¤é 6 ÈÖÌܤκÂÀʤò»Ø¤¹¡£

­£¡¡¿Þ¤ÎÌֳݤ±¤ÎÀʤϡ¤Í½ÌóºÑ¤Ç¤¢¤ë¡£

(2)¡¡Ï¢Â³¤·¤Æ³ÎÊݤ·¤¿¤¤´õ˾ÀÊ¿ô¤ò¡¤°ú¿ô number ¤Ë³ÊǼ¤·¤Æ¥×¥í¥°¥é¥à¤ËÅϤ¹¡£

(3)¡¡ºÂÀʤϡ¤¥¹¥Æ¡¼¥¸¤Ë¸þ¤«¤Ã¤ÆºÇÁ°Îóº¸Ã¼¡ÊA Îó 1 È֡ˤ«¤é¡¤Æ±°ìÎó¤Ë´õ˾ÀÊ¿ô¤ÎÆþ¤ëϢ³¤·¤¿¶õ¤­¤¬¤¢¤ë¤«¤É¤¦¤«¤òÄ´¤Ù¡¤ºÇ½é¤Ë¸«¤Ä¤«¤Ã¤¿¶õ¤­¤ò³ÎÊݤ¹¤ë¡£ AÎó¤Ç³ÎÊݤǤ­¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¡¤½ç¼¡ B Îó¡¤C Îó¡¤¡Ä ¤È¸åÎó¤ËÂФ·¤Æº¸Ã¼¤«¤é¡¤´õ˾ÀÊ¿ô¤ÎÆþ¤ëϢ³¤·¤¿¶õ¤­¤¬¤¢¤ë¤«¤òÄ´¤Ù¡¤ºÇ½é¤Ë¸«¤Ä¤«¤Ã¤¿¶õ¤­¤ò³ÎÊݤ¹¤ë¡£Á´ÀÊõ¤·¤Æ¤â¶õ¤­¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¤ºÂÀʤ¬³ÎÊݤǤ­¤Ê¤«¤Ã¤¿¤â¤Î¤È¤¹¤ë¡£

(4)¡¡´õ˾¿ô¤ÎºÂÀʤ¬³ÎÊݤǤ­¤¿¾ì¹ç¤Ï¡¤¤½¤ÎºÂÀʤÎÎó̾¤È¡¤³ÎÊݤǤ­¤¿ºÂÀʤÎÃæ¤Ç¡¤¥¹¥Æ¡¼¥¸¤Ë¸þ¤«¤Ã¤ÆºÇ¤âº¸Ã¼¤Ë°ÌÃÖ¤¹¤ëºÂÀʤÎÈÖ¹æ¤È¤ò³ÊǼ¤·¤¿ºÂÀÊÈֹ湽¤ÂΡÊSEAT¡Ë¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò¡¤ÊÖµÑÃͤȤ·¤ÆÊÖ¤¹¡£³ÎÊݤǤ­¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¡¤¶õ¥Ý¥¤¥ó¥¿¡ÊNULL¡Ë¤òÊÖµÑÃͤȤ·¤ÆÊÖ¤¹¡£

(5)¡¡¹½Â¤ÂÎ SEAT ¤ÎÀë¸À¤Ï¡¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£


typedef struct {
    char    row;        /* ºÂÀʤÎÎó̾ */
    int     no;         /* ºÂÀʤÎÈÖ¹æ */
} SEAT;

(6)¡¡¥³¥ó¥µ¡¼¥È²ñ¾ì¤Î³ÆºÂÀʤξõ¶·¤Ï¡¤Âç°èÊÑ¿ô status ¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ë¡£ºÂÀʤ¬³ÎÊݤǤ­¤¿¾ì¹ç¤Ë¤Ï¡¤³ÎÊݤǤ­¤¿ºÂÀʤòͽÌóºÑ¤Ë¤¹¤ë¡£

¡¡¡¡

Îó A ¡Á Z ¤ËÂбþ¤¹¤ëź»ú i ¤ÎÃÍ¤Ï 0 ¡Á 25 ¤Ë¤Ê¤ë¡£ÈÖ 1 ¡Á n ¤ËÂбþ¤¹¤ëź»ú j ¤ÎÃÍ¤Ï 0 ¡Á n ¡Ý 1 ¤Ë¤Ê¤ë¡£

¡Ì¥×¥í¥°¥é¥à¡Í


#define MAXNUM 30     /* Îó¤ÎºÇÂçºÂÀÊ¿ô */
#define ROWNUM 26     /* Îó¿ô */
typedef struct {
    char    row;      /* ºÂÀʤÎÎó̾ */
    int     no;       /* ºÂÀʤÎÈÖ¹æ */
} SEAT;
static char rname[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}, 
            status[ROWNUM][MAXNUM];
static int  cnum[ROWNUM] = {12, 14, 16, 18, 20, 22, 24, 26, 28,30, 30, 30, 30, 30, 30, 30, 30, 28, 26, 24, 22, 20, 18, 16, 14,12};
static SEAT empty;
SEAT *book_seat(int);
SEAT *book_seat(int number)
{
    int ridx, cidx, eidx, flg = 0;
    for (ridx = 0; ridx < ROWNUM; ridx++) {    
        for (cidx = 0; cidx <= cnum[ridx] - number; cidx++) {
            if (status[ridx][cidx] == ' ') {
                ;
                for (eidx = ; cidx < eidx; eidx--)
                    if (status[ridx][eidx] == 'R') {
                        flg = 0;
                        break;
                    }
                if (flg == 1) break;
            }
        }
        if (flg == 1) break;
    }
    if (flg == 0)
        return NULL;
    for (eidx = cidx + number - 1; cidx <= eidx; eidx--)
        status[ridx][eidx] = 'R';
    empty.row = ;
    empty.no  = ;
    return &empty;
}

ÀßÌä¡¡¥×¥í¥°¥é¥àÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

a ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡cidx++¡¡¡¡¡¡¡¡¡¡¡¡¡¡¥¤¡¡cidx--

¥¦¡¡cidx += number¡¡¡¡¡¡¥¨¡¡cidx += number - 1

¥ª¡¡flg = 0¡¡¡¡¡¡¡¡¡¡¡¡¡¡¥«¡¡flg = 1

b ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡0¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¥¤¡¡cidx

¥¦¡¡cidx + 1¡¡¡¡¡¡¡¡¡¡¡¡¡¡¥¨¡¡cidx + number

¥ª¡¡cidx + number - 1¡¡¡¡¡¡¥«¡¡number

¥­¡¡number - 1

c ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡ridx¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¥¤¡¡ridx + 1

¥¦¡¡ridx - 1¡¡¡¡¡¡¡¡¡¡¡¡¥¨¡¡rname[ridx]

¥ª¡¡rname[ridx + 1]¡¡¡¡¡¡¥«¡¡rname[ridx - 1]

d ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡cidx¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¥¤¡¡cidx + 1¡¡¡¡¡¡¡¡¥¦¡¡cidx - 1

¥¨¡¡ridx + cidx¡¡¡¡¡¡¡¡¥ª¡¡ridx - cidx


Ì䣷 ¡¡¼¡¤Î COBOL ¥×¥í¥°¥é¥à¤ÎÀâÌÀµÚ¤Ó¥×¥í¥°¥é¥à¤òÆɤó¤Ç¡¤ÀßÌä¤ËÅú¤¨¤è¡£

¡Ì¥×¥í¥°¥é¥à¤ÎÀâÌÀ¡ÍͽÌó¾õ¶·¥Õ¥¡¥¤¥ë¤ÈÎÁ¶â¥Õ¥¡¥¤¥ë¤«¤é¡¤¥Ñ¥é¥á¥¿¤ÇÍ¿¤¨¤é¤ì¤¿¸¡º÷¾ò·ï¤òËþ¤¿¤¹½ÉÇñ»ÜÀߤζõ¼¼¤ò¸¡º÷¤·¤Æ¡¤½ÉÇñÎÁ¶â¤Î°Â¤¤½ç¤Ëʤ٤¿¶õ¼¼¾ðÊó¤òÊÖ¤¹Éû¥×¥í¥°¥é¥à¤Ç¤¢¤ë¡£

(1)¡¡Í½Ìó¾õ¶·¥Õ¥¡¥¤¥ë BOOKING-FILE ¤Î¥ì¥³¡¼¥ÉÍͼ°¤Ï¡¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

»ÜÀߥ³¡¼¥É
¡¡¡¡3 ¤±¤¿

Éô²°Ì¾¾Î
¡¡¡¡10 ¤±¤¿

Éô²°¥¿¥¤¥×
¡¡¡¡2 ¤±¤¿

ͽÌó¾õ¶·
¡¡¡¡1 ¤±¤¿ ¡ß 366

­¡¡¡»ÜÀߥ³¡¼¥É¤Ï½ÉÇñ»ÜÀߤòɽ¤·¡¤³Æ»ÜÀߤˤÏÊ£¿ô¤ÎÉô²°¤¬¤¢¤ë¤â¤Î¤È¤¹¤ë¡£

­¢¡¡Í½Ìó¾õ¶·¤Ï¡¤366 ¸Ä¤ÎÍ×ÁǤ«¤é¤Ê¤ë £±¼¡¸µ¤Îɽ¤Ç¤¢¤ê¡¤¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ëÍâÆü¤«¤é £±Ç¯´Öʬ¤ÎͽÌó¾õ¶·¤òɽ¤·¤Æ¤¤¤ë¡£

­£¡¡Í×ÁǤÎÃͤ¬¡¤0 ¤Î¤È¤­¤Ï¡ÈͽÌó¤Ê¤·¡É¤ò¼¨¤·¡¤1 ¤Î¤È¤­¤Ï¡ÈͽÌóºÑ¡É¤ò¼¨¤¹¡£Í½Ìó¾õ¶·¥Õ¥¡¥¤¥ë¤ÏËèÆü¹¹¿·¤µ¤ì¡¤¥×¥í¥°¥é¥à¼Â¹Ô»þ¤Ë¤Ï¡¤¤½¤ì¤Þ¤Ç¤ÎͽÌó¾õ¶·¤¬Àµ¤·¤¯È¿±Ç¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤È¤¹¤ë¡£

Îã¡¡¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ëÆü¤¬ 2003 ǯ 10 ·î 19 Æü¤Î¤È¤­¤Ï¡¤ 2003 ǯ 10 ·î 20Æü¡Á 2004 ǯ 10 ·î 19 Æü¤ÎͽÌó¾õ¶·¤¬³ÊǼ¤µ¤ì¤Æ¤¤¤ë¡£

(2)¡¡ÎÁ¶â¥Õ¥¡¥¤¥ë CHARGE-FILE ¤ÏÉô²°¥¿¥¤¥×¤ò¼ç¥­¡¼¤È¤¹¤ëº÷°ú¥Õ¥¡¥¤¥ë¤Ç¤¢¤ê¡¤¥ì¥³¡¼¥ÉÍͼ°¤Ï¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

­¡¡¡½ÉÇñ¿Í¿ô¡§1 Éô²°¤ËÇñ¤Þ¤ë¿Í¿ô¤ò¼¨¤¹¡£

­¢¡¡½ÉÇñÎÁ¶â¡§Éô²°¤Î 1 ¿ÍÅö¤¿¤ê¤Î 1 ÇñÎÁ¶â¤ò¼¨¤¹¡£½ÉÇñ¿Í¿ô¤Î°ã¤¤¤Ë¤è¤Ã¤Æ 4 Ä̤êÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¡£

­£¡¡Í½Ìó¾õ¶·¥Õ¥¡¥¤¥ë¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ëÉô²°¥¿¥¤¥×¤Ë³ºÅö¤¹¤ë¥ì¥³¡¼¥É¤Ï¡¤É¬¤ºÂ¸ºß¤¹¤ë¡£

(3)¡¡¸¡º÷¾ò·ï SEARCH-INFO ¤Î·Á¼°¤Ï¡¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£¸¡º÷¾ò·ï¤ÇÍ¿¤¨¤é¤ì¤ë¥Ç¡¼¥¿¤ÏÀµ¤·¤¤¤â¤Î¤È¤¹¤ë¡£

»ÜÀߥ³¡¼¥É
¡¡¡¡3 ¤±¤¿

½ÉÇñ³«»ÏÆü
¡¡¡¡8 ¤±¤¿

½ÉÇñÆü¿ô
¡¡¡¡2 ¤±¤¿

½ÉÇñ¿Í¿ô
¡¡¡¡2 ¤±¤¿

1 Çñ¤Îͽ»»

²¼¸Â
¡¡¡¡6 ¤±¤¿

¾å¸Â
¡¡¡¡6 ¤±¤¿

­¡¡¡»ÜÀߥ³¡¼¥É¡§3 ¤±¤¿¤Î¿ô»ú¤Ç¤¢¤ë¡£ ¡È000¡É¤Î¤È¤­¤Ï»ÜÀߤλØÄ꤬¤Ê¤¤¤³¤È¤òɽ¤¹¡£

­¢¡¡½ÉÇñ³«»ÏÆü¡§4 ¤±¤¿¤ÎÀ¾Îñǯ¡¤2 ¤±¤¿¤Î·î¡¤2 ¤±¤¿¤ÎÆü¤Ç¹½À®¤µ¤ì¤Æ¤¤¤ë¡£¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ëÍâÆü¤«¤é 1 ǯ°ÊÆâ¤ÎÆüÉդȤ¹¤ë¡£

Îã¡¡2003 ǯ 10 ·î 20 Æü¤Ê¤é¤Ð¡È20031020¡É¤È¤Ê¤ë¡£

­£¡¡½ÉÇñÆü¿ô¡§2 ¤±¤¿¤Î 0 ¤Ç¤Ê¤¤¿ô»ú¤Ç¤¢¤ë¡£½ÉÇñ³«»ÏÆü¤«¤éϢ³¤·¤ÆÇñ¤Þ¤ëÆü¿ô¤òɽ¤¹¡£Ï¢Â³¤·¤ÆÇñ¤Þ¤ëÆü¤ò´Þ¤á¤Æ¡¤¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ëÍâÆü¤«¤é£±Ç¯´Ö¤Ë¼ý¤Þ¤ëÆü¿ô¤È¤¹¤ë¡£

Îã¡¡1 Çñ 2 Æü¤Î¤È¤­¤Ï¡¤¡È01¡É¤È¤Ê¤ë¡£

­¤¡¡½ÉÇñ¿Í¿ô¡§2 ¤±¤¿¤Î 0 ¤Ç¤Ê¤¤¿ô»ú¤Ç¤¢¤ë¡£

­¥¡¡1 Çñ¤Îͽ»»¡§1 ¿ÍÅö¤¿¤ê¤Î 1 Çñ¤Îͽ»»¤Ç¤¢¤ê¡¤²¼¸Â¤È¾å¸Â¤ò¼¨¤¹ 1 ÁȤΠ6 ¤±¤¿¤Î¿ô»ú¤Ç¤¢¤ë¡£²¼¸Â¤È¾å¸Â¤¬¤È¤â¤Ë¡È000000¡É¤Î¤È¤­¤Ï»ØÄê¤Ê¤·¤òɽ¤¹¡£

Îã¡¡10,000 ¡Á 15,000 ±ß¤ÎÉô²°¤ò¸¡º÷¤¹¤ë¤È¤­¤Ï¡¤¡¡²¼¸Â¤È¤·¤Æ¡È010000¡É¡¤¾å¸Â¤È¤·¤Æ¡È015000¡É¤ò»ØÄꤹ¤ë¡£

(4)¡¡¸¡º÷·ë²Ì SEARCH-RESULT ¤Î·Á¼°¤Ï¡¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

­¡¡¡¶õ¼¼¾ðÊó¤Ï 100 ¸Ä¤ÎÍ×ÁǤ«¤é¤Ê¤ë 1 ¼¡¸µ¤Îɽ¤Ç¤¢¤ê¡¤¸¡º÷·ë²Ì¤Ï 100 ·ï°Ê²¼¤È¤¹¤ë¡£¸¡º÷·ë²Ì¤¬ 100 ·ï̤Ëþ¤Î¤È¤­¡¤»Ä¤ê¤ÎÍ×ÁǤϡ¤¶õÇò¤ÇËä¤á¤é¤ì¤Æ¤¤¤ë¡£

­¢¡¡¶õ¼¼¾ðÊó¤Ï¡¤½ÉÇñÎÁ¶â¤Î°Â¤¤½ç¤Ëʤ٤롣

(5)¡¡Éû¥×¥í¥°¥é¥à GETDAYS ¤ò»ÈÍѤ¹¤ë¡£ GETDAYS ¤Ï¡¤Í¿¤¨¤é¤ì¤¿ÆüÉեǡ¼¥¿¤ò¡¤¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ëÍâÆü¤«¤é¤ÎÄÌ»»Æü¤ËÊÑ´¹¤¹¤ë¡£ GETDAYS ¤Î¸Æ¤Ó½Ð¤·ÊýË¡¤Ï¡¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

¡¡¡¡CALL "GETDAYS" USING ÆüÉÕ ÄÌ»»Æü

¡Ì¥×¥í¥°¥é¥à¡Í


DATA              DIVISION.
FILE              SECTION.
FD  BOOKING-FILE.
01  BOOKING-REC.
    03  BCODE             PIC   9(03).
    03  BNAME             PIC   X(10).
    03  BTYPE             PIC   X(02).
    03  BOOKING-INFO      PIC   9(01)  OCCURS 366.
FD  CHARGE-FILE.
01  CHARGE-REC.
    03  CTYPE             PIC   X(02).
    03  ACCOMMODATION-INFO             OCCURS 4.
        05  GUEST-NO      PIC   9(02).
        05  CHARGE        PIC   9(06).
SD  VACANCY-FILE.
01  VACANCY-REC.
    03  VCODE             PIC   9(03).
    03  VNAME             PIC   X(10).
    03  VCHARGE           PIC   9(06).
WORKING-STORAGE   SECTION.
01  EOF                   PIC   X(01).
01  BOOKING-FLAG          PIC   9(01).
01  DAYS                  PIC   9(03).
01  MATCH                 PIC   9(01).
01  I                     PIC   9(03).
01  J                     PIC   9(01).
LINKAGE           SECTION.
01  SEARCH-INFO.
    03  SCODE             PIC   9(03).
    03  CHECKIN-DATE      PIC   9(08).
    03  STAY-DAYS         PIC   9(02).
    03  SGUEST-NO         PIC   9(02).
    03  SCHARGE-RANGE.
        05  LOWER-LIMIT   PIC   9(06).
        05  UPPER-LIMIT   PIC   9(06).
01  SEARCH-RESULT.
    03  SEARCH-COUNT      PIC   9(03).
    03  VACANCY-INFO      PIC   X(19)  OCCURS 100.
PROCEDURE         DIVISION  USING  SEARCH-INFO SEARCH-RESULT.
MAIN-PROC.
    SORT VACANCY-FILE
        
        INPUT PROCEDURE SEARCH-PROC
        OUTPUT PROCEDURE RESULT-PROC.
    EXIT PROGRAM.
SEARCH-PROC.
    OPEN INPUT BOOKING-FILE CHARGE-FILE.
    MOVE SPACE TO EOF.
    READ BOOKING-FILE AT END
       MOVE "E" TO EOF
    END-READ.
    PERFORM UNTIL EOF = "E"
       IF (SCODE = ZERO OR
           SCODE = BCODE) THEN
          CALL "GETDAYS" USING CHECKIN-DATE DAYS
          MOVE 0 TO BOOKING-FLAG
          PERFORM 
             IF BOOKING-INFO(I) = 1 THEN
                MOVE 1 TO BOOKING-FLAG
             END-IF
          END-PERFORM
          IF  THEN
             MOVE BTYPE TO CTYPE
             READ CHARGE-FILE
             MOVE 0 TO MATCH
             PERFORM VARYING J FROM 1 BY 1
                     UNTIL J > 4 OR MATCH = 1
                IF  THEN
                   MOVE BCODE TO VCODE
                   MOVE BNAME TO VNAME
                   MOVE CHARGE(J) TO VCHARGE
                   RELEASE VACANCY-REC
                   MOVE 1 TO MATCH
                END-IF
             END-PERFORM
          END-IF
       END-IF
       READ BOOKING-FILE AT END
          MOVE "E" TO EOF
       END-READ
    END-PERFORM.
    CL OS E  BOOKING-FILE CHARGE-FILE.
RESULT-PROC.
    INITIALIZE SEARCH-RESULT.
    MOVE SPACE TO EOF.
    RETURN VACANCY-FILE AT END
       MOVE "E" TO EOF
    END-RETURN.
    PERFORM UNTIL EOF = "E"
       COMPUTE SEARCH-COUNT = SEARCH-COUNT + 1
       MOVE VACANCY-REC TO VACANCY-INFO(SEARCH-COUNT)
       RETURN VACANCY-FILE AT END
          MOVE "E" TO EOF
       END-RETURN
    END-PERFORM.

ÀßÌä¡¡¥×¥í¥°¥é¥àÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

a ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡OCCURS KEY VCHARGE

¥¤¡¡ON ASCENDING KEY VCHARGE

¥¦¡¡ON DESCENDING KEY VCHARGE

¥¨¡¡SORT KEY VCHARGE

¥ª¡¡USING KEY VCHARGE

b ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡VARYING I FROM 1 BY 1 UNTIL I > DAYS

¥¤¡¡VARYING I FROM 1 BY 1 UNTIL I > DAYS OR BOOKING-FLAG = 1

¥¦¡¡VARYING I FROM 1 BY 1 UNTIL I >= STAY-DAYS

¥¨¡¡VARYING I FROM 1 BY 1 UNTIL I >= STAY-DAYS

¡¡¡¡OR BOOKING-FLAG = 1

¥ª¡¡VARYING I FROM DAYS BY 1

¡¡¡¡UNTIL I >= DAYS + STAY-DAYS OR BOOKING-FLAG = 1

c ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡BOOKING-FLAG = 0

¥¤¡¡BOOKING-FLAG = 1

¥¦¡¡BOOKING-INFO(I) = 0

¥¨¡¡BOOKING-INFO(I) = 1

¥ª¡¡SCODE = ZERO

¥«¡¡SCODE NOT = ZERO

d ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡(GUEST-NO(J) = SGUEST-NO AND

¡¡¡¡(SCHARGE-RANGE = ZERO OR

¡¡¡¡(CHARGE(J) >= LOWER-LIMIT AND CHARGE(J) <= UPPER-LIMIT)))

¥¤¡¡(GUEST-NO(J) = SGUEST-NO AND

¡¡¡¡(SCHARGE-RANGE NOT = ZERO AND

¡¡¡¡(CHARGE(J) < LOWER-LIMIT OR CHARGE(J) > UPPER-LIMIT)))

¥¦¡¡(GUEST-NO(J) = SGUEST-NO OR

¡¡¡¡(SCHARGE-RANGE = ZERO OR

¡¡¡¡(CHARGE(J) >= LOWER-LIMIT AND CHARGE(J) <= UPPER-LIMIT)))

¥¨¡¡NOT (GUEST-NO(J) NOT = SGUEST-NO AND

¡¡¡¡(SCHARGE-RANGE = ZERO OR

¡¡¡¡(CHARGE(J) >= LOWER-LIMIT AND CHARGE(J) <= UPPER-LIMIT)))

¥ª¡¡NOT (GUEST-NO(J) NOT = SGUEST-NO AND

¡¡¡¡(SCHARGE-RANGE NOT = ZERO AND

¡¡¡¡(CHARGE(J) < LOWER-LIMIT OR CHARGE(J) > UPPER-LIMIT)))


Ì䣸 ¡¡¼¡¤Î Java ¥×¥í¥°¥é¥à¤ÎÀâÌÀµÚ¤Ó¥×¥í¥°¥é¥à¤òÆɤó¤Ç¡¤ÀßÌä¤ËÅú¤¨¤è¡£

¡Ì¥×¥í¥°¥é¥à¤ÎÀâÌÀ¡Í

¥×¥í¥°¥é¥à¤Ï¡¤¥Ð¥¤¥Ê¥ê¥Ç¡¼¥¿¤Î¥Ð¥¤¥ÈÎó¤ò¤¢¤ë¥¢¥ë¥´¥ê¥º¥à¤Ë½¾¤Ã¤ÆÊÑ´¹¤·¡¤¤½¤Î·ë²Ì¤òʸ»ú¤ÎÎó¤È¤·¤Æ¼èÆÀ¤¹¤ë¤¿¤á¤Î¥¯¥é¥¹ Encoder ¤È¤½¤Î¥Æ¥¹¥ÈÍÑ¥¯¥é¥¹¤«¤é¤Ê¤ë¡£ÊÑ´¹¥¢¥ë¥´¥ê¥º¥à¤Ï¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

(1)¡¡¥Ð¥¤¥ÈÎó¤ÎÀèƬ¤«¤é½ç¤Ë 6 ¥Ó¥Ã¥È¤º¤Ä¼è¤ê½Ð¤·¡¤ÊÑ´¹É½¤ÎÂбþ¤¹¤ëʸ»ú¤ËÊÑ´¹¤¹¤ë¡£¤¿¤À¤·¡¤¥Ð¥¤¥È¿ô¤¬ 3 ¤ÎÇÜ¿ô¤Ç¤Ê¤¤¤È¤­¤Ï¡¤¥Ó¥Ã¥È¿ô¤¬ 6 ¤ÎÇÜ¿ô¤Ë¤Ê¤ë¤è¤¦¤Ë¡¤ºÇ¸å¤Ë 4 ¥Ó¥Ã¥ÈËô¤Ï 2 ¥Ó¥Ã¥È¤Î 0 ¤¬¤¢¤ë¤â¤Î¤È¤¹¤ë¡£

(2)¡¡ÊÑ´¹¸å¤Îʸ»ú¿ô¤¬¡¤Í¿¤¨¤é¤ì¤¿¥Ð¥¤¥È¿ô¤Î 4¡¿3 Çܰʾå¤ÇºÇ¤â¾®¤µ¤¤ 4 ¤ÎÇÜ¿ô¤Ë¤Ê¤ë¤è¤¦¤Ë¡¤Ê¸»ú¤ÎÎó¤ÎºÇ¸å¤ËɬÍפʸĿô¤À¤±¡È=¡É¤òÉղ乤롣

(3)¡¡ÊÑ´¹Îã¤ò¿Þ£± ¤Ë¼¨¤¹¡£


¡¡¡¡¿Þ£±¡¡ÊÑ´¹Îã

(4)¡¡¥¯¥é¥¹ Encoder ¤Ï¡¤next ¤È hasNext ¤ÎÆó¤Ä¤Î¥á¥½¥Ã¥É¤ò¤â¤Ä¡£ next ¤Ï¡¤ÊÑ´¹¥¢¥ë¥´¥ê¥º¥à¤Ë½¾¤Ã¤ÆÊÑ´¹¤µ¤ì¤¿Ê¸»ú¤ò 1 ʸ»ú¤º¤Ä½ç¤ËÊÖ¤¹¥á¥½¥Ã¥É¤Ç¤¢¤ë¡£ÊÖ¤¹¤Ù¤­Ê¸»ú¤¬¤Ê¤¯¤Ê¤Ã¤¿¸å¤Ë¸Æ¤Ð¤ì¤ë¤È¡¤¡£

java.util.NoSuchElementException ¤òÅꤲ¤ë¡£ hasNext ¤Ï¡¤¼¡¤Î next ¸Æ½Ð¤·¤ÎºÝ¤Ë¡¤Îã³°¤¬È¯À¸¤»¤º¤Ëʸ»ú¤òÊÖ¤¹¤³¤È¤¬¤Ç¤­¤ë¤È¤­¿¿¤È¤Ê¤ë¡£

(5)¡¡ÊÑ¿ô CHARS ¤Ï¡¤6 ¥Ó¥Ã¥È¤Î¿ôÃͤò 1 ʸ»ú¤ËÊÑ´¹¤¹¤ë¤¿¤á¤Îɽ¤Ç¡¤ÇÛÎó¤ÎÂ礭¤µ¤Ï 64 ¤Ç¤¢¤ë¡£ÊÑ¿ô n ¤Ï¡¤¼¡¤Ë next ¤¬¸Æ¤Ð¤ì¤¿¤È¤­¤ËÊÖ¤¹¤Ù¤­Ê¸»ú¤¬²¿ÈÖÌܤÎʸ»ú¤Ç¤¢¤ë¤«¤òÊÝ»ý¤¹¤ë¡ÊÀèƬ¤Îʸ»ú¤Ï 0 ÈÖÌܤȤ¹¤ë¡Ë¡£ÊÑ¿ô bin ¤Ï¡¤ÊÑ´¹¤¹¤ë¥Ð¥¤¥Ê¥ê¥Ç¡¼¥¿¤ÎÎó¤òÊÝ»ý¤¹¤ë¡£

(6)¡¡¿Þ£± ¤Î¥Ð¥¤¥ÈÎó¤òÍѤ¤¤¿¥Æ¥¹¥ÈÍÑ¥¯¥é¥¹ EncoderTest ¤Î¼Â¹Ô·ë²Ì¤ò¿Þ£² ¤Ë¼¨¤¹¡£

EjRFZw==¡¡¡¡¡¡¡¡¡¡¡¡ 

¿Þ£²¡¡¼Â¹Ô·ë²Ì

¡Ì¥×¥í¥°¥é¥à¡Í


public class Encoder {
   static final char[] CHARS = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
   "abcdefghijklmnopqrstuvwxyz0123456789+/").toCharArray();
   private int n = 0;
   private byte[] bin;
   public Encoder(byte[] bin) {
      if (bin == null) this.bin = new byte[0];
      else this.bin = bin;
   }
   public boolean hasNext() {
      return n < ;
   }
   public char next() {
      char letter;
      int pos = (int)(n * 0.75);
      // ÊÑ´¹ÂоݤΠ6 ¥Ó¥Ã¥È¤Î¥Ç¡¼¥¿¤¬´Þ¤Þ¤ì¤ë 2 ¥Ð¥¤¥È¤Î¥Ç¡¼¥¿¤ò¼èÆÀ
      if (pos < bin.length) {
         int cell = bin[pos++] << 8;
         if (pos < bin.length) cell += bin[pos] & 255;
         // ÊÑ´¹¤¹¤Ù¤­ 6 ¥Ó¥Ã¥È¤òÃê½Ð¤·, Âбþ¤¹¤ë 1 ʸ»ú¤ËÊÑ´¹
         letter = CHARS[(cell >> (n + 3) % 4 * 2 + 4) & 63];
      } else {
         if ()
            throw new java.util.NoSuchElementException();
         else letter = ;
      }
      n++;
      return letter;
   }
}
class EncoderTest {
   public static void main(String[] args) {
      byte[] bin = {0x12, 0x34, 0x45, 0x67};
      Encoder encoder = new Encoder(bin);
      while (encoder.hasNext()) {
         System.out.print(encoder.next());
      }
      System.out.println();
   }
}

ÀßÌä¡¡¥×¥í¥°¥é¥àÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

a ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡(bin.length + 2) * 4 / 3¡¡¡¡¡¡¡¡¥¤¡¡(bin.length + 2) / 3 * 4

¥¦¡¡bin.length * 4 / 3¡¡¡¡¡¡¡¡¥¨¡¡bin.length / 3 * 4

b ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡!hasNext()¡¡¡¡¡¡¡¡¡¡¥¤¡¡hasNext()

¥¦¡¡n < bin.length¡¡¡¡¡¡¡¡¥¨¡¡n >= bin.length()

c ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡''¡¡¡¡¡¡¡¡¡¡¥¤¡¡'='

¥¦¡¡CHARS[n]¡¡¡¡¡¡¡¡¡¡¥¨¡¡next()


Ì䣹 ¡¡¼¡¤Î¥¢¥»¥ó¥Ö¥é¥×¥í¥°¥é¥à¤ÎÀâÌÀµÚ¤Ó¥×¥í¥°¥é¥à¤òÆɤó¤Ç¡¤ÀßÌä 1¡¤2 ¤ËÅú¤¨¤è¡£

¡Ì¥×¥í¥°¥é¥à¤ÎÀâÌÀ¡Í

Éû¥×¥í¥°¥é¥à SUBS ¤Ï¡¤¼¡¤Ë¼¨¤¹¤è¤¦¤Ë»ØÄꤵ¤ì¤¿Ê¸»úÎó¤Î°ìÉôʬ¡ÊÉôʬʸ»úÎó¤È¸Æ¤Ö¡Ë¤ò¡¤»ØÄꤵ¤ì¤¿Îΰè¤ËÊ£¼Ì¤¹¤ë¥×¥í¥°¥é¥à¤Ç¤¢¤ë¡£

(1)¡¡GR1 ¡Á GR5 ¤Ë¡¤¼¡¤ÎÃͤ¬ÀßÄꤵ¤ì¤Æ¡¤¼ç¥×¥í¥°¥é¥à¤«¤éÅϤµ¤ì¤ë¡£

GR1¡§Ê¸»úÎ󤬳ÊǼ¤µ¤ì¤Æ¤¤¤ëÎΰè¤ÎÀèƬ¥¢¥É¥ì¥¹

GR2¡§Ê¸»úÎó¤ÎŤµ L

GR3¡§Éôʬʸ»úÎó¤Î³«»Ï°ÌÃÖ P¡Ê0 ¡å P ¡ã L¡Ë

GR4¡§Éôʬʸ»úÎó¤ÎŤµ Lp

GR5¡§Éôʬʸ»úÎó¤òÊ£¼Ì¤¹¤ëÎΰè¤ÎÀèƬ¥¢¥É¥ì¥¹

¤¿¤À¤·¡¤Éôʬʸ»úÎó¤ÎÎΰè¤ÈÊ£¼ÌÀè¤Îʸ»úÎó¤ÎÎΰè¤Ï½Å¤Ê¤é¤Ê¤¤¡£

(2)¡¡¼¡¤Ë¼¨¤¹¤É¤Á¤é¤«¤Î½èÍý·ë²Ì¤ò GR0 ¤ËÀßÄꤷ¤Æ¼ç¥×¥í¥°¥é¥à¤ËÌá¤ë¡£

0¡¡¡¡Àµ¾ï¤Ë½ªÎ»

-1¡¡¡¡Ä¹¤µ»ØÄê¤Ë¸í¤ê¡ÊP ¡Ü Lp ¡ä L¡Ë

(3)¡¡Éû¥×¥í¥°¥é¥à¤«¤éÌá¤ë¤È¤­¡¤ÈÆÍѥ쥸¥¹¥¿ GR1 ¡Á GR7 ¤ÎÆâÍƤϸµ¤ËÌ᤹¡£

¡Ì¥×¥í¥°¥é¥à¡Í


¡Ê¹ÔÈÖ¹æ¡Ë
 1  SUBS  START
 2        RPUSH
 3        LD      GR7,GR3
 4        ADDA    GR7,GR4
 5        CPA     GR2,GR7          ; Ťµ¤Î¥Á¥§¥Ã¥¯
 6        JMI     SETER
 7        ADDL    GR3,GR1
 8  LOOP  LD      GR4,GR4
 9        JZE     SETS
10        
11        ST      GR0,0,GR5        ; ʸ»ú¤ò³ÊǼ¤¹¤ë
12        LAD     GR3,1,GR3
13        
14        LAD     GR5,1,GR5
15        JUMP    LOOP
16  SETER LAD     GR0,-1           ; ¥¨¥é¡¼¤òÀßÄꤹ¤ë
17        JUMP    FIN
18  SETS  LAD     GR0,0            ; Àµ¾ï½ªÎ»¤òÀßÄꤹ¤ë
19  FIN   RPOP
20        RET
21        END

ÀßÌ䣱¡¡¥×¥í¥°¥é¥àÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

²òÅú·²

¥¢¡¡LAD GR2,1,GR2¡¡¡¡¡¡¡¡¥¤¡¡LAD GR2,-1,GR2

¥¦¡¡LAD GR4,1,GR4¡¡¡¡¡¡¡¡¥¨¡¡LAD GR4,-1,GR4

¥ª¡¡LD GR0,0,GR3¡¡¡¡¡¡¡¡¥«¡¡LD GR0,0,GR4

¥­¡¡LD GR1,0,GR3¡¡¡¡¡¡¡¡¥¯¡¡LD GR1,0,GR4


ÀßÌ䣲¡¡¼¡¤Îµ­½ÒÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

SUBS ¤Î»ÅÍͤǤϡ¤P ¡Ü Lp ¡ä L ¤Î¾ì¹ç¡¤Ä¹¤µ»ØÄê¤Ë¸í¤ê¤¬¤¢¤ë¤È¤·¤Æ¤¤¤ë¡£¤³¤ì¤ò¸í¤ê¤È¤·¤Ê¤¤¤Ç¼¡¤Î¤È¤ª¤ê¤ËÊѹ¹¤¹¤ë¡£

(1)¡¡Ê¸»úÎó¤Î½ª¤ï¤ê¤Þ¤Ç¤òÊ£¼Ì¤¹¤ë¡£

(2)¡¡Ê£¼Ì¤Ç¤­¤¿Éôʬʸ»úÎó¤ÎŤµ¤ò GR0 ¤ËÀßÄꤹ¤ë¡£

¤½¤Î¤¿¤á¤Ë¡¤SUBS ¤Î½èÍý¤ò¼¡¤Î¤è¤¦¤ËÊѹ¹¤¹¤ë¡£ (1) ¤ËÂбþ¤¹¤ë½¤Àµ¤È¤·¤Æ¡¤¹ÔÈÖ¹æ 7 ¤Ë¥é¥Ù¥ë GETPS ¤òÄɲä·¡¤¹ÔÈÖ¹æ 16¡¤17 ¤Î 2 ¹Ô¤ò¼¡¤Î¤è¤¦¤ËÊѹ¹¤¹¤ë¡£

SETER¡¡LD¡¡¡¡¡¡¡¡GR4,GR2
¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡JUMP¡¡¡¡GETPS

(2) ¤ËÂбþ¤¹¤ë½¤Àµ¤È¤·¤Æ¡¤¹ÔÈÖ¹æ 7 ¤Îľ¸å¤Ç ¤ÎÃͤò°ì»þÊݸ¤·¡¤¹ÔÈÖ¹æ 18 ¤Ç¤³¤ÎÃͤò GR0 ¤ËÀßÄꤹ¤ë¡£

c ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡SUBA GR3,GR2¡¡¡¡¡¡¡¡¥¤¡¡SUBA GR4,GR2

¥¦¡¡SUBA GR4,GR3¡¡¡¡¡¡¡¡¥¨¡¡SUBA GR5,GR4

d ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡GR1¡¡¡¡¡¡¡¡¥¤¡¡GR2¡¡¡¡¡¡¡¡¥¦¡¡GR3¡¡¡¡¡¡¡¡¥¨¡¡GR4¡¡¡¡¡¡¡¡¥ª¡¡GR5


Ìä10 ¡¡¼¡¤Î C ¥×¥í¥°¥é¥à¤ÎÀâÌÀµÚ¤Ó¥×¥í¥°¥é¥à¤òÆɤó¤Ç¡¤ÀßÌä 1¡¤2 ¤ËÅú¤¨¤è¡£

¡Ì¥×¥í¥°¥é¥à¤ÎÀâÌÀ¡Í

ɽ·×»»¥½¥Õ¥È¤Ê¤É¤Ç»ÈÍѤµ¤ì¤ë¥Ç¡¼¥¿¸ò´¹½èÍýÍÑ¤Î¥×¥í¥°¥é¥à¤Ç¤¢¤ë¡£

(1)¡¡´Ø¿ô loadcsv ¤Ï¡¤(2) ¤Ë¼¨¤¹Íͼ°¡ÊCSV ·Á¼°¤È¸Æ¤Ö¡Ë¤Î¥ì¥³¡¼¥É¤ò¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë¤«¤éÆɤ߹þ¤ß¡¤2 ¼¡¸µÇÛÎó¤Îɽ¤Ë³ÊǼ¤¹¤ë¡£´Ø¿ô savecsv ¤Ï¡¤É½Æâ¤ÎÍ×ÁǤò CSV ·Á¼°¤ËÌᤷ¤Æ¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë¤Ë½ÐÎϤ¹¤ë¡£

(2)¡¡¤³¤Î¥×¥í¥°¥é¥à¤Ç°·¤¦ CSV ·Á¼°¤Î»ÅÍͤϡ¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

­¡¡¡Ê¸»úÎ󤫤é¤Ê¤ë¥Ç¡¼¥¿¤ò¥³¥ó¥Þ¡È,¡É¤Ç¶èÀڤäÆʤ٤¿¤â¤Î¤Ç¤¢¤ë¡£

­¢¡¡¥³¥ó¥Þ¤ÎÁ°¸å¤Ë¤Ï¶õÇò¤¬µö¤µ¤ì¤ë¡£

­£¡¡Ê¸»úÎó¤Ï¡¤Á´ÂΤò°úÍÑÉä¤Ç°Ï¤ó¤Ç¤â°Ï¤Þ¤Ê¤¯¤Æ¤â¤è¤¤¡£¤¿¤À¤·¡¤Ê¸»úÎóÆâ¤Ë¶õÇòʸ»ú¡¤¥³¥ó¥Þ¡È,¡É¤ò´Þ¤à¾ì¹ç¤Ë¤Ï¡¤¿Þ£± ¤Î¤è¤¦¤Ëʸ»úÎóÁ´ÂΤò°úÍÑÉä¤Ç°Ï¤à¡£Ê¸»úÎóÆâ¤Ë°úÍÑÉä¤Ï´Þ¤Þ¤Ê¤¤¤â¤Î¤È¤¹¤ë¡£

­¤¡¡CSV ·Á¼°¥Õ¥¡¥¤¥ë¤Ë¤Ï¡¤É½¤Î 1 ¹Ô¤ËÂбþ¤¹¤ë¥Ç¡¼¥¿·²¤¬ 1 ¥ì¥³¡¼¥É¤È¤·¤Æ³ÊǼ¤µ¤ì¤Æ¤¤¤ë¡£

­¥¡¡¥ì¥³¡¼¥É¤Î½ªÃ¼¤Ï¡È \n ¡É¤Ç¤¢¤ë¡£

Shop-A, 1, "1,000", "21,000", "3,000"
Shop-B, 2, "4,500", "15,000", "4,000"

¿Þ£±¡¡CSV ·Á¼°¤Î¥Ç¡¼¥¿Îã¡Ê2 ¥ì¥³¡¼¥É¡Ë

(3)¡¡¥ì¥³¡¼¥ÉÆâ¤Îʸ»úÎó¤Ï¡¤Æ°Åª¤Ë³ÎÊݤ·¤¿Îΰè¤Ë³ÊǼ¤·¡¤É½¤ÎÍ×ÁǤˤϤ½¤ÎÎΰè¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò³ÊǼ¤¹¤ë¡£

(4)¡¡°úÍÑÉä¤Ç°Ï¤Þ¤ì¤¿¥Ç¡¼¥¿·Á¼°¤Î¾ì¹ç¤Ï¡¤Æ°Åª¤Ë³ÎÊݤ·¤¿Îΰè¤ËÁ°¸å¤Î°úÍÑÉä¤ò½ü¤¤¤¿Ê¸»úÎó¤ò³ÊǼ¤¹¤ë¡£

(5)¡¡Âбþ¤¹¤ë¥Ç¡¼¥¿¤¬¤Ê¤¤Í×ÁǤˤϡ¤NULL ¤ò³ÊǼ¤¹¤ë¡£

(6)¡¡¿Þ£± ¤Î¥ì¥³¡¼¥É¤ò³ÊǼ¤·¤¿É½¤ò¿Þ£² ¤Ë¼¨¤¹¡£

¿Þ£²¡¡CSV ·Á¼°¤Î¥Ç¡¼¥¿¤ò³ÊǼ¤·¤¿É½¤ÎÎã¡Ê2 ¥ì¥³¡¼¥É¡Ë

(7)¡¡¤³¤³¤Ç»ÈÍѤµ¤ì¤ëʸ»ú¤Î¼ïÎà¤Ï¡¤JIS X 0201 ¡Ê7 ¥Ó¥Ã¥ÈµÚ¤Ó 8 ¥Ó¥Ã¥È¤Î¾ðÊó¸ò´¹ÍÑÉä¹æ²½Ê¸»ú½¸¹ç¡Ë¤Îʸ»ú¤È¤¹¤ë¡£

(8)¡¡É½¤Î¹Ô¿ôµÚ¤ÓÎó¿ô¤ÎºÇÂçÃͤϡ¤¤È¤â¤Ë 64 ¤È¤·¡¤¥ì¥³¡¼¥É¤Îʸ»úĹ¤Ï 255 °Ê²¼¤È¤¹¤ë¡£

(9)¡¡CSV ·Á¼°¥Õ¥¡¥¤¥ëÆâ¤Î¥ì¥³¡¼¥É¤Ëµ­½Ò¤Î¸í¤ê¤Ï¤Ê¤¤¤â¤Î¤È¤·¡¤¥Õ¥¡¥¤¥ëÆþ½ÐÎϤǤΥ¨¥é¡¼¤âȯÀ¸¤·¤Ê¤¤¤â¤Î¤È¤¹¤ë¡£

(10)¡¡³Æ´Ø¿ô¤Î»ÅÍͤϡ¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

­¡¡¡´Ø¿ô loadcsv

·Á¼°¡§¡¡int loadcsv( char fname[], char *tbl[][TBLSZ] );

°ú¿ô¡§¡¡fname¡¡¡¡ÆþÎÏ¥Õ¥¡¥¤¥ë̾¤Ø¤Î¥Ý¥¤¥ó¥¿

¡¡¡¡¡¡¡¡tbl¡¡É½¡Ê2 ¼¡¸µÇÛÎó¡Ë¤Ø¤Î¥Ý¥¤¥ó¥¿¡Ê¤³¤³¤Ç¡¤TBLSZ ¤Ï¡¤É½¤Î¹Ô¿ôµÚ¤ÓÎó¿ô¤ÎºÇÂçÃÍ¡Ë

ÊÖµÑÃÍ¡§¡¡É½¤Ë³ÊǼ¤·¤¿¥ì¥³¡¼¥É¿ô

­¢¡¡´Ø¿ô savecsv

·Á¼°¡§¡¡void savecsv( char fname[], char *tbl[][TBLSZ],
¡¡¡¡¡¡int ln );

°ú¿ô¡§¡¡fname¡¡¡¡½ÐÎÏ¥Õ¥¡¥¤¥ë̾¤Ø¤Î¥Ý¥¤¥ó¥¿

tbl¡¡¡¡¡¡É½¡Ê2 ¼¡¸µÇÛÎó¡Ë¤Ø¤Î¥Ý¥¤¥ó¥¿

ln¡¡¡¡¡¡¡¡½ÐÎϤ¹¤ë¥ì¥³¡¼¥É¿ô

¡Ì¥×¥í¥°¥é¥à¡Í


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define  TBLSZ   64
#define  RECSZ   256
int  loadcsv( char*, char*[][TBLSZ] );
void savecsv( char*, char*[][TBLSZ], int );
int loadcsv( char fname[], char *tbl[][TBLSZ] )
{
    FILE *fp;
    char buf[RECSZ], *cp, *dp;
    int  col, row, len;
    
    for ( row = 0; row < TBLSZ; row++ ) {
        for ( col = 0; col < TBLSZ; col++ ) tbl[row][col] = NULL;
    }
    fp = fopen( fname, "r" );
    for ( row = 0; fgets( buf, RECSZ, fp ) != NULL; row++ ) {
        col = 0;      
        for ( cp = buf; *cp != '\n'; cp++ ) {
            while ( *cp == ' ' ) cp++;     /* ¶õÇò¤ÎÆɤßÈô¤Ð¤· */
            if ( *cp == '\n' ) break;
            else if ( *cp == ',' ) ;  /* ¥³¥ó¥Þ¤Î½èÍý */
            else {
                if ( *cp == '\"' ) { /* ¥Ç¡¼¥¿¤¬°úÍÑÉä¤Ç°Ï¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç */
                    dp = ;
                    for ( len = 0; *cp != '\"'; len++,  );
                }
                else {
                    dp = ;
                    for ( len = 0; *cp != '\n'; len++,  )
                      if (( *cp == ' ' ) || ( *cp == ',' ) 
                        || ( *cp == '\n' )) break;
                    ;
                }
                if ( len != 0 ) { /* ¥Ç¡¼¥¿¤¬¶õ¤Ç¤Ê¤¤¾ì¹ç */
                    tbl[row][col] = malloc( len+1 );
                                  /* ưŪ¤ËÎΰè¤ò³ÎÊÝ */
                    strncpy( tbl[row][col], dp, len );
                    *(tbl[row][col]+len) = '\0';
                }
            }
        }
    }
    fclose( fp );
    return row;
}
void savecsv( char fname[], char *tbl[][TBLSZ], int ln )
{
    FILE *fp;
    int   row, col, last;
    fp = fopen( fname, "w" );
    for ( row = 0; row < ln; row++ ) {
        for ( last = TBLSZ-1; last >= 0; last-- )
            if ( tbl[row][last] != NULL ) break;
        for ( col = 0; col <= last; col++ ) {
            if ( tbl[row][col] != NULL ) {
                fputs( "\"", fp );
                fputs( tbl[row][col], fp );
                fputs( "\"", fp );
            }
            if ( col < last ) fputs( ",", fp );
        }
        fputs( "\n", fp );
    }
    fclose( fp );
}

ÀßÌ䣱¡¡¥×¥í¥°¥é¥àÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£¤Ê¤ª¡¤²òÅú¤Ï½ÅÊ£¤·¤ÆÁª¤ó¤Ç¤â¤è¤¤¡£

a ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡col++¡¡¡¡¡¡¡¡¥¤¡¡dp = NULL¡¡¡¡¡¡¡¡¥¦¡¡dp++

¥¨¡¡len++¡¡¡¡¡¡¡¡¥ª¡¡tbl[row][col] = NULL

b ¡Á e ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡cp¡¡¡¡¡¡¡¡¥¤¡¡cp--¡¡¡¡¡¡¡¡¥¦¡¡cp+1¡¡¡¡¡¡¡¡¥¨¡¡++cp


ÀßÌ䣲¡¡¼¡¤Î CSV ·Á¼°¤Î 2 ¥ì¥³¡¼¥É¤ò´Ø¿ô loadcsv ¤Ë¤è¤Ã¤Æɽ¤Ë³ÊǼ¤·¡¤¤½¤ì¤«¤é´Ø¿ô savecsv ¤Ë¤è¤Ã¤Æ CSV ·Á¼°¤Ç½ÐÎϤ¹¤ë¡£½ÐÎÏ·ë²Ì¤ÎÀâÌÀ¤È¤·¤ÆŬÀڤʤâ¤Î¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

"Taro Yamada", 43, "175.5", M, "550,000"
Hanako-Yamada, 12, "156.7", F,

²òÅú·²

¥¢¡¡¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¤ËÂФ·¤Æ¡¤°úÍÑÉä¤Ç°Ï¤ó¤À¤â¤Î¤ò¥³¥ó¥Þ¤Ç¶èÀڤäƽÐÎϤ¹¤ë¡£³Æ¥ì¥³¡¼¥É¤ÎËöÈø¤Ë¤Ï¡¤ÉÔÍפʥ³¥ó¥Þ¤Ï½ÐÎϤµ¤ì¤Ê¤¤¡£

"Taro Yamada","43","175.5","M","550,000"
"Hanako-Yamada","12","156.7","F"

¥¤¡¡¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¤ËÂФ·¤Æ¡¤°úÍÑÉä¤Ç°Ï¤ó¤À¤â¤Î¤ò¥³¥ó¥Þ¤Ç¶èÀڤäƽÐÎϤ¹¤ë¡£½ÐÎϥ쥳¡¼¥É¤Î¥Ç¡¼¥¿¸Ä¿ô¤ÏºÇÂç¤Î¤â¤Î¤Ë¤½¤í¤¨¤é¤ì¤ë¡£

"Taro Yamada","43","175.5","M","550,000"
"Hanako-Yamada","12","156.7","F",""

¥¦¡¡ÆþÎÏ»þ¤ÈƱ¤¸·Á¼°¤Ç½ÐÎϤ¹¤ë¡£½ÐÎϥ쥳¡¼¥É¤Î¥Ç¡¼¥¿¸Ä¿ô¤ÏºÇÂç¤Î¤â¤Î¤Ë¤½¤í¤¨¤é¤ì¤ë¡£

"Taro Yamada",43,"175.5",M,"550,000"
Hanako-Yamada,12,"156.7",F,

¥¨¡¡ÆþÎÏ»þ¤ÈƱ¤¸·Á¼°¤Ç½ÐÎϤ¹¤ë¡£¥ì¥³¡¼¥É¤ÎËöÈø¤Ë¤Ï¡¤ÉÔÍפʥ³¥ó¥Þ¤Ï½ÐÎϤµ¤ì¤Ê¤¤¡£

"Taro Yamada",43,"175.5",M,"550,000"
Hanako-Yamada,12,"156.7",F


Ìä11 ¡¡¼¡¤Î COBOL ¥×¥í¥°¥é¥à¤ÎÀâÌÀµÚ¤Ó¥×¥í¥°¥é¥à¤òÆɤó¤Ç¡¤ÀßÌä¤ËÅú¤¨¤è¡£

¡Ì¥×¥í¥°¥é¥à¤ÎÀâÌÀ¡Í¹Ò¶õÊؤò»È¤Ã¤¿Î¹Äø¤ÎÃæ¤Ç¡¤½ÐȯÃϤζõ¹Á¤«¤éÌÜŪÃϤζõ¹Á¤Þ¤Ç¤ÎÈô¹Ô»þ´Ö¤È¾è·Ñ»þ´Ö¤òµá¤á¤ë¥×¥í¥°¥é¥à¤Ç¤¢¤ë¡£½Ðȯ¤¹¤ë¶õ¹Á¤ÈÆü»þµÚ¤ÓÅþÃ夹¤ë¶õ¹Á¤ÈÆü»þ¤ò°ìÁȤˤ·¤¿¥ì¥³¡¼¥É¤ò¡¤ÍøÍѤ¹¤ë¹Ò¶õÊؤοô¤À¤±¥Õ¥¡¥¤¥ë¤Ë³ÊǼ¤·¤Æ¤¢¤ë¡£³ÊǼ¤µ¤ì¤Æ¤¤¤ëÆü»þ¤Ï¤½¤ì¤¾¤ì¤Î¶õ¹Á¤Î¸½ÃÏÆü»þ¤Ç¤¢¤ë¡£³Æ¶õ¹Á¤Î¸½ÃÏ»þ´Ö¤ÎÀ¤³¦É¸½à»þ¤«¤é¤Î»þº¹¤ò³ÊǼ¤·¤¿º÷°ú¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Ê¤¬¤é¡¤°ìÏ¢¤Î¹Ò¶õÊؤÎÈô¹Ô»þ´Ö¡¤Èô¹Ô»þ´Ö¹ç·×µÚ¤Ó¾è·Ñ»þ´Ö¹ç·×¤òµá¤á¤Æ°õ»ú¤¹¤ë¡£¤³¤ÎÌäÂê¤Ç¤Ï¡¤²Æ»þ´Ö¤Ï¹Íθ¤·¤Ê¤¤¡£

(1)¡¡Èô¹ÔͽÄê¾ðÊó¥Õ¥¡¥¤¥ë itinerary-file ¤Ï¡¤¼¡¤Î¥ì¥³¡¼¥ÉÍͼ°¤Î½ç¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£

ÊØ̾
6 ¤±¤¿

½Ðȯ¶õ¹Á¤ÈÆü»þ

ÅþÃå¶õ¹Á¤ÈÆü»þ

¶õ¹Á

¥³¡¼¥É
3 ¤±¤¿

ÆüÉÕ
8 ¤±¤¿

»þ¹ï

¶õ¹Á

¥³¡¼¥É
3 ¤±¤¿

ÆüÉÕ
8 ¤±¤¿

»þ¹ï

»þ
2 ¤±¤¿

ʬ
2 ¤±¤¿

»þ
2 ¤±¤¿

ʬ
2 ¤±¤¿

­¡¡¡¥×¥í¥°¥é¥à¤Ç¤Ï¡¤¡È½Ðȯ¶õ¹Á¤ÈÆü»þ¡É¤ò·«ÊÖ¤·¹àÌܤΠ1 ÈÖÌܤÎÍ×ÁǤǡ¤ ¡ÈÅþÃå¶õ¹Á¤ÈÆü»þ¡É¤ò·«ÊÖ¤·¹àÌܤΠ2 ÈÖÌܤÎÍ×ÁǤÇɽ¸½¤·¤Æ¤¤¤ë¡£

­¢¡¡¥ì¥³¡¼¥É¤Ï¡¤ÂоݤȤʤëιÄø¤ÇÍøÍѤ¹¤ë¹Ò¶õÊؤνçÈ֤˳ÊǼ¤µ¤ì¤Æ¤¤¤ë¡£¤¢¤ë¥ì¥³¡¼¥É¤ÎÅþÃå»þ¹ï¤«¤é¼¡¤Î¥ì¥³¡¼¥É¤Î½Ðȯ»þ¹ï¤Þ¤Ç¤¬¾è·Ñ»þ´Ö¤Ç¤¢¤ë¡£°ì¤Ä¤Î¹Ò¶õÊؤÇľÀÜÌÜŪÃϤËÅþ㤹¤ë¾ì¹ç¤Ï¡¤¥ì¥³¡¼¥É¤Ï°ì¤Ä¤Ç¤¢¤ê¡¤¾è·Ñ¤®¤Ï¤Ê¤¤¡£

­£¡¡ÊØ̾¤Ï 6 ¤±¤¿°ÊÆâ¤Î±Ñ¿ô»ú¹àÌܤǤ¢¤ê¡¤º¸µÍ¤á¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ë¡£

­¤¡¡¶õ¹Á¥³¡¼¥É¤Ï¡¤±Ñ»ú 3 ʸ»ú¤Î¥³¡¼¥É¤Ç¤¢¤ê¡¤¥³¡¼¥É¤Ï½ÅÊ£¤·¤Ê¤¤¡£

­¥¡¡ÆüÉդϡ¤4 ¤±¤¿¤ÎÀ¾Îñǯ YYYY¡¤2 ¤±¤¿¤Î·î MM µÚ¤Ó 2 ¤±¤¿¤ÎÆü DD ¤ò¡¤ YYYYMMDD ¤Î·Á¤Î 10 ¿Ê¿ô¤È¤·¤Æ³ÊǼ¤·¤Æ¤¤¤ë¡£

(2)¡¡¶õ¹Á¤È¸½ÃÏ»þ´Ö¤ÎÀ¤³¦É¸½à»þ¤«¤é¤Î»þº¹¤ò³ÊǼ¤¹¤ë¥Õ¥¡¥¤¥ë airports-file ¤Î¥ì¥³¡¼¥ÉÍͼ°¤Ï¡¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

¶õ¹Á¥³¡¼¥É

3 ¤±¤¿

À¤³¦É¸½à»þ¤«¤é¤Î»þº¹

»þ
3 ¤±¤¿

ʬ
2 ¤±¤¿

­¡¡¡3 ʸ»ú¤Î¶õ¹Á¥³¡¼¥É¤ò¥­¡¼¤È¤¹¤ëº÷°ú¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£

­¢¡¡À¤³¦É¸½à»þ¤«¤é¤Î»þº¹¤Î¡È»þ¡É¤Ï¡¤Éä¹æÉÕ¤­¿ô»ú¹àÌܤǤ¢¤ê¡¤ 1 ¤±¤¿¤ÎÉä¹æ¤Ë³¤¯ 2 ¤±¤¿¤Î¿ô»ú¤Çɽ¸½¤µ¤ì¤Æ¤¤¤ë¡£ ¡Èʬ¡É¤Ï¡¤Éä¹æ¤Ê¤·¿ô»ú¹àÌܤǤ¢¤ë¡£

­£¡¡Èô¹ÔͽÄê¾ðÊó¥Õ¥¡¥¤¥ë¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ë¶õ¹Á¥³¡¼¥É¤Ï¡¤É¬¤º¥Õ¥¡¥¤¥ëÃæ¤Ë¸ºß¤¹¤ë¡£

(3)¡¡°ìÏ¢¤Î¹Ò¶õÊؤÎÈô¹Ô»þ´Ö¡¤Èô¹Ô»þ´Ö¹ç·×µÚ¤Ó¾è·Ñ»þ´Ö¹ç·×¤Î°õ»úÎã¤ò¡¤¿Þ£± ¤Ë¼¨¤¹¡£¤³¤Î¤È¤­¤Î¥×¥í¥°¥é¥à¤Ø¤ÎÆþÎϤϡ¤¿Þ£² ¤ÎÈô¹ÔͽÄê¾ðÊó¥Õ¥¡¥¤¥ë¤È¿Þ£³ ¤Î¶õ¹Á¤È¸½ÃÏ»þ´Ö¤ÎÀ¤³¦É¸½à»þ¤«¤é¤Î»þº¹¤ò³ÊǼ¤¹¤ë¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£³Æ¹Ò¶õÊؤˤĤ¤¤Æ¡¤ÊØ̾¡¤½Ðȯ¶õ¹Á¥³¡¼¥É¡¤½ÐȯÆüÉÕ¡¤½Ðȯ»þ¹ï¡¤ÅþÃå¶õ¹Á¥³¡¼¥É¡¤ÅþÃåÆüÉÕ¡¤ÅþÃå»þ¹ï¡¤Èô¹Ô»þ´Ö¤ò°õ»ú¤·¡¤ºÇ¸å¤ËÈô¹Ô»þ´Ö¹ç·×µÚ¤Ó¾è·Ñ»þ´Ö¹ç·×¤ò°õ»ú¤¹¤ë¡£Èô¹Ô»þ´Ö¹ç·×¤È¾è·Ñ»þ´Ö¹ç·×¤Ï¡¤¤½¤ì¤¾¤ì 100 »þ´Ö̤Ëþ¤È¤¹¤ë¡£

¿Þ£±¡¡°õ»úÎã

XY1234ABC200309271715DEF200309271030
YX4567DEF200309271200GHI200309271530

¡¡¡¡¡¡¿Þ£²¡¡Èô¹ÔͽÄê¾ðÊó¥Õ¥¡¥¤¥ë¤ÎÎã

¡¡¡¡¡¡ABC+0700¡¡¡¡¡¡ 
¡¡¡¡¡¡DEF-1000
¡¡¡¡¡¡GHI-0900
¡¡¡¡¡¡JFK-0500
¡¡¡¡¡¡LAX-0800
¡¡¡¡¡¡NRT+0900
¡¡¡¡¡¡ORD-0600
¡¡¡¡¡¡SAN-0800

¿Þ£³¡¡¶õ¹Á¤È¸½ÃÏ»þ´Ö¤ÎÀ¤³¦É¸½à»þ¤«¤é¤Î»þº¹¤ò³ÊǼ¤¹¤ë¥Õ¥¡¥¤¥ë¤ÎÎã

(4)¡¡¥×¥í¥°¥é¥àÃæ¤Ç»È¤ï¤ì¤Æ¤¤¤ëÁȹþ¤ß´Ø¿ô INTEGER-OF-DATE ¤Ï¡¤Èô¹ÔͽÄê¾ðÊó¥Õ¥¡¥¤¥ë¤ÎÆüÉդηÁ¼°¤ÎÀ°¿ô¤ò°ú¿ô¤È¤·¤Æ¼õ¤±¼è¤ê¡¤¥°¥ì¥´¥ê¥ªÎñ¤Ç 1600 ǯ 12 ·î 31 Æü¤«¤é¤½¤ÎÆü¤Þ¤Ç¤ÎÁíÆü¿ô¤òÊÖ¤¹¡£

¡Ì¥×¥í¥°¥é¥à¡Í


DATA DIVISION.
FILE SECTION.
FD  airports-file.
01  airport-timediff-rec.
  05  3-letter-code              PIC X(3).
  05  local-timediff.
    10  local-hh-diff            PIC S9(2) LEADING SEPARATE.
    10  local-mm-diff            PIC 9(2).
FD  itinerary-file.
01  flight-schedule.
  05  flight-number              PIC X(6).
  05  flight-time-and-location occurs 2.
    10  airport-of-call          PIC X(3).
    10  arrv-dprt-date-grp. 
      15  arrv-dprt-date         PIC 9(8).
    10  arrv-dprt-time.
      15  arrv-dprt-hh           PIC 9(2).
      15  arrv-dprt-mm           PIC 9(2).
WORKING-STORAGE SECTION.
01  departure                    PIC 9 VALUE 1.
01  arrival                      PIC 9 VALUE 2.
01  this-airport                 PIC 9.
01  .
  05  normalized-minutes         PIC 9(9)  OCCURS 2.
01  arrival-normalized-minutes   PIC 9(9).
01  time-in-minutes              PIC 9(9).
01  time-diff-in-minutes         PIC S9(9).
01  flight-minutes               PIC S9(9).
01  transit-minutes              PIC S9(9).
01  accumulated-flight-minutes   PIC 9(9).
01  accumulated-transit-minutes  PIC 9(9).
01  elapsed-time-hhmm.
  05  elapsed-hours              PIC 9(2).
  05                             PIC X     VALUE ":".
  05  elapsed-minutes            PIC 9(2).
01  end-of-itinerary-file        PIC X.
PROCEDURE DIVISION.
main-paragraph.
    OPEN INPUT airports-file itinerary-file.
    MOVE "n" TO end-of-itinerary-file.
    INITIALIZE accumulated-flight-minutes
               accumulated-transit-minutes
               arrival-normalized-minutes
               transit-minutes.
    PERFORM UNTIL end-of-itinerary-file = "y"
       READ itinerary-file AT END
          MOVE "y" TO end-of-itinerary-file
       NOT AT END
          PERFORM calculate-flight-time
          ADD transit-minutes TO accumulated-transit-minutes
          ADD flight-minutes TO accumulated-flight-minutes
          PERFORM display-flight-time
       END-READ
    END-PERFORM.
    PERFORM display-accumulated-time.
    CL OS E airports-file itinerary-file.
    STOP RUN.
calculate-flight-time.
    MOVE arrival TO this-airport.
    PERFORM normalize-time.
    MOVE departure TO this-airport.
    PERFORM normalize-time.
    IF  THEN
       COMPUTE transit-minutes
             = 
    END-IF.
    COMPUTE flight-minutes
          = .
    MOVE normalized-minutes(arrival) 
         TO arrival-normalized-minutes.
normalize-time.
    MOVE  TO 3-letter-code.
    READ airports-file.
    IF 0 <= local-hh-diff THEN
       COMPUTE time-diff-in-minutes
             = local-hh-diff * 60 + local-mm-diff
    ELSE
       COMPUTE time-diff-in-minutes
             = local-hh-diff * 60 - local-mm-diff
    END-IF.
    COMPUTE 
       = (FUNCTION INTEGER-OF-DATE(arrv-dprt-date(this-airport))
        * 24 + arrv-dprt-hh(this-airport))
        * 60 + arrv-dprt-mm(this-airport) - time-diff-in-minutes.
display-flight-time.
    MOVE flight-minutes TO time-in-minutes.
    PERFORM transform-minutes-to-hhmm.
    DISPLAY flight-number                  " "
            airport-of-call(departure)     " "
            arrv-dprt-date-grp(departure)  " "
            arrv-dprt-time(departure)      " to "
            airport-of-call(arrival)       " "
            arrv-dprt-date-grp(arrival)    " "
            arrv-dprt-time(arrival)        ", flight time = "
            elapsed-time-hhmm.
display-accumulated-time.
    MOVE accumulated-flight-minutes TO time-in-minutes.
    PERFORM transform-minutes-to-hhmm.
    DISPLAY "Total flight time  = " elapsed-time-hhmm.
    MOVE accumulated-transit-minutes TO time-in-minutes.
    PERFORM transform-minutes-to-hhmm.
    DISPLAY "Total transit time = " elapsed-time-hhmm.
transform-minutes-to-hhmm.
    DIVIDE time-in-minutes BY 60
           GIVING elapsed-hours
           REMAINDER elapsed-minutes.

ÀßÌä¡¡¥×¥í¥°¥é¥àÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

a ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡0¡¡ < arrival-normalized-minutes

¥¤¡¡0¡¡ < normalized-minutes(arrival)

¥¦¡¡0¡¡ < normalized-minutes(departure)

¥¨¡¡0 ¡¡= arrival-normalized-minutes

b¡¤c ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡arrival-normalized-minutes - normalized-minutes(departure)

¥¤¡¡normalized-minutes(arrival) - normalized-minutes(departure)

¥¦¡¡normalized-minutes(departure) - arrival-normalized-minutes

¥¨¡¡normalized-minutes(departure) - normalized-minutes(arrival)

¥ª¡¡normalized-minutes(this-airport) -

normalized-minutes(departure)

d¡¤e ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡airport-of-call(arrival)

¥¤¡¡airport-of-call(this-airport)

¥¦¡¡normalized-minutes

¥¨¡¡normalized-minutes(arrival)

¥ª¡¡normalized-minutes(this-airport)

¥«¡¡this-airport


Ìä12 ¡¡¼¡¤Î Java ¥×¥í¥°¥é¥à¤ÎÀâÌÀµÚ¤Ó¥×¥í¥°¥é¥à¤òÆɤó¤Ç¡¤ÀßÌä¤ËÅú¤¨¤è¡£

¡Ì¥×¥í¥°¥é¥à¤ÎÀâÌÀ¡Í

¥¯¥é¥¹ Matrix ¤Ï¡¤Í×ÁǤÎÃͤ¬¼Â¿ô¤Ç¤¢¤ë¹ÔÎó¤òɽ¤¹¥¯¥é¥¹¤Ç¤¢¤ê¡¤¼ç¤Ê¹ÔÎó±é»»¤Î¤¿¤á¤Î¥á¥½¥Ã¥É¤òÄêµÁ¤¹¤ë¡£¥¯¥é¥¹ MatrixTest ¤Ï¡¤¥¯¥é¥¹ Matrix ¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ò¥Æ¥¹¥È¤¹¤ë¥á¥½¥Ã¥É main ¤òÄêµÁ¤¹¤ë¥¯¥é¥¹¤Ç¤¢¤ë¡£¥¯¥é¥¹ Matrix ¤Î»ÅÍͤϡ¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

(1)¡¡¥¯¥é¥¹ Matrix ¤Î¥³¥ó¥¹¥È¥é¥¯¥¿¤Ï¡¤¹ÔÎó¤ÎÍ×ÁǤÎÃͤò´Þ¤à double[][] ·¿¤Î°ú¿ô¤ò¤â¤Ä¡£¹ÔµÚ¤ÓÎó¤Ï null ¤Ç¤Ï¤Ê¤¯¡¤³Æ¹Ô¤ÎÍ×ÁǤθĿô¤ÏƱ°ì¤Ç¤¢¤ë¤È¤¹¤ë¡£¶õ¹ÔÎó¤Ï¹Í¤¨¤Ê¤¤¡£

(2)¡¡¥á¥½¥Ã¥É toString ¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤ë¹ÔÎ󥪥֥¸¥§¥¯¥È¤Îʸ»úÎóɽ¸½¤Ï¡¤¼¡¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£

[[1 ¹Ô 1 Îó 1 ¹Ô 2 Îó ¡Ä 1 ¹Ô N Îó] ¡Ä [M ¹Ô 1 Îó M ¹Ô 2 Îó ¡Ä M ¹Ô N Îó]]

MatrixTest Îã 1 ¹ÔÎó ¤Îʸ»úÎóɽ¸½¤Ï¡¤[[1.0 2.0][3.0 4.0]] ¤È¤Ê¤ë¡£

(3)¡¡¥á¥½¥Ã¥É add ¤Ë¡¤¹ÔÎ󥪥֥¸¥§¥¯¥È¤Î°ú¿ô¤òÅϤ¹¤È¡¤¥ª¥Ö¥¸¥§¥¯¥È this ¤È°ú¿ô¤Î¥ª¥Ö¥¸¥§¥¯¥È¤È¤ÎϤιÔÎó¤òÊÖ¤¹¡£¹ÔÎó¤ÎϤϡ¤Æó¤Ä¤Î¹ÔÎó¤Î¹Ô¿ô¤ÈÎó¿ô¤¬¤½¤ì¤¾¤ìÅù¤·¤¤¾ì¹ç¤Ë¤À¤±ÄêµÁ¤µ¤ì¤ë¡£

MatrixTest Îã 2 ¹ÔÎó ¤È¹ÔÎó ¤È¤ÎϤϡ¤ ¤Ë¤Ê¤ë¡£¥ª¥Ö¥¸¥§¥¯¥È this ¤È¤ÎϤ¬ÄêµÁ¤µ¤ì¤Ê¤¤¹ÔÎ󥪥֥¸¥§¥¯¥È¤¬°ú¿ô¤ËÅϤµ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¤Îã³° MatrixArithmeticException ¤òÅꤲ¤ë¡£

(4)¡¡¥á¥½¥Ã¥É multiply ¤Ë¡¤¼Â¿ô¤Î°ú¿ô¤òÅϤ¹¤È¡¤¥ª¥Ö¥¸¥§¥¯¥È this ¤ÎÍ×ÁǤ´¤È¤Ë¤½¤Î°ú¿ô¤ò¾è»»¤·¤¿·ë²Ì¤Î¹ÔÎó¤òÊÖ¤¹¡£

MatrixTest Îã 3 ¹ÔÎó ¤È¼Â¿ô 2.0 ¤È¤ÎÀѤϡ¤ ¤Ë¤Ê¤ë¡£

(5)¡¡¥á¥½¥Ã¥É multiply ¤Ë¡¤¹ÔÎ󥪥֥¸¥§¥¯¥È¤Î°ú¿ô¤òÅϤ¹¤È¡¤¥ª¥Ö¥¸¥§¥¯¥È this ¤È°ú¿ô¤Î¥ª¥Ö¥¸¥§¥¯¥È¤È¤ÎÀѤιÔÎó¤òÊÖ¤¹¡£ k ¹Ô l Îó¤Î¹ÔÎó A ¤È¡¤ m ¹Ô n Îó¤Î¹ÔÎó B ¤È¤ÎÀÑ A B ¤Ï¡¤¹ÔÎó A ¤ÎÎó¿ô¤È¹ÔÎó B ¤Î¹Ô¿ô¤¬Åù¤·¤¤¡¤¤¹¤Ê¤ï¤Á l ¡á m ¤Ç¤¢¤ë¤È¤­¤Ë¤À¤±ÄêµÁ¤µ¤ì¤ë¡£ A B ¡á C ¤È¤¹¤ë¤È¤­¡¤ÀѤιÔÎó C ¤Ï k ¹Ô n Îó¤Ë¤Ê¤ë¡£¤³¤Î¤È¤­¡¤¹ÔÎó C ¤ÎÂè i ¹ÔÂè j Îó¤ÎÍ×ÁǤÎÃͤϡ¤¹ÔÎó A ¤Î i ¹Ô x Îó¡Ê¤³¤³¤Ç¡¤ x ¡á 1¡¤¡Ä¡¤ l ¡Ë ¤ÎÃͤȹÔÎó B ¤Î x ¹Ô j Îó¤ÎÃͤȤò³Ý¤±¤ÆÆÀ¤é¤ì¤ë l ¸Ä¤Î¼Â¿ô¤ÎϤǤ¢¤ë¡£

MatrixTest Îã 4 ¹ÔÎó ¤È¹ÔÎó ¤È¤ÎÀѤϡ¤ ¤Ë¤Ê¤ë¡£¥ª¥Ö¥¸¥§¥¯¥È this ¤È¤ÎÀѤ¬ÄêµÁ¤µ¤ì¤Ê¤¤¹ÔÎ󥪥֥¸¥§¥¯¥È¤¬°ú¿ô¤ËÅϤµ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¤Îã³° MatrixArithmeticException ¤òÅꤲ¤ë¡£

¡Ì¥×¥í¥°¥é¥à¡Í


class MatrixArithmeticException extends Exception { }
public class Matrix {
   private double[][] values;
   public Matrix(double[][] initVal) {
      values = new double[initVal.length][initVal[0].length];
      // ÇÛÎó initVal ¤ÎÆâÍƤòÇÛÎó values ¤Ë¥³¥Ô¡¼¤¹¤ë
      for (int i = 0; i < initVal.length; i++) {
         System.arraycopy(initVal[i], 0, values[i], 0, 
                          initVal[i].length);
      }
   }
   public Matrix add(Matrix m) throws MatrixArithmeticException {
      if ()
         throw new MatrixArithmeticException();
      double[][] result = 
         new double[values.length][values[0].length];
      for (int i = 0; i < values.length; i++) { 
         for (int j = 0; j < values[0].length; j++) { 
            result[i][j] = values[i][j] + m.values[i][j];
         }
      }
      ;
   }
   public Matrix multiply(Matrix m) 
      throws MatrixArithmeticException {
      if () 
         throw new MatrixArithmeticException();
      double[][] result = 
         new double[values.length][m.values[0].length];
      for (int i = 0; i < values.length; i++) {
         for (int j = 0; j < m.values[0].length; j++) {
            for (int k = 0; k < m.values.length; k++) {
               result[i][j] += values[i][k] * m.values[k][j];
            }
         }
      }
      ;
   }
   public Matrix multiply(double d) {
      double[][] result = 
         new double[values.length][values[0].length];
      for (int i = 0; i < values.length; i++) {
         for (int j = 0; j < values[0].length; j++) {
            result[i][j] = values[i][j] * d; 
         }
      }
      ;
   }
   public String toString() { 
      StringBuffer rep = new StringBuffer("[");
      for (int i = 0; i < values.length; i++) {
         rep.append("[");
         for (int j = 0; j < values[0].length; j++) {
            rep.append(((j > 0) ? " " : "") + values[i][j]);
         }
         rep.append("]");
      }
      rep.append("]");
      ;
   }
}
class MatrixTest {
   public static void main(String[] args) 
    throws MatrixArithmeticException {
    // Îã 1
    Matrix matrix0 = 
     new Matrix(new double[][]{{1.0, 2.0}, {3.0, 4.0}});
    System.out.println(matrix0);
    // Îã 2
    Matrix matrix1 = 
     new Matrix(new double[][]{{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}});
    Matrix matrix2 = 
     new Matrix(new double[][]{{1.2, 1.3, 1.4}, {1.5, 1.6, 1.7}});
    System.out.println(matrix1.add(matrix2));
    // Îã 3
    double d = 2.0;
    System.out.println(matrix0.multiply(d));
    // Îã 4
    Matrix matrix3 = 
     new Matrix(new double[][]{{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}});
    Matrix matrix4 = 
     new Matrix(new double[][]{{1.0, 0.0}, {0.0, 1.0}, {1.0, 0.0}});
    System.out.println(matrix3.multiply(matrix4));
    }
}

ÀßÌä¡¡¥×¥í¥°¥é¥àÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

a¡¤c ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡values.length == m.values[0].length

¥¤¡¡values.length != m.values[0].length

¥¦¡¡values[0].length == m.values.length

¥¨¡¡values[0].length != m.values.length

¥ª¡¡values.length == m.values.length &&

¡¡¡¡values[0].length == m.values[0].length

¥«¡¡values.length != m.values.length ||

¡¡¡¡values[0].length != m.values[0].length

¥­¡¡values[0].length == m.values.length &&

¡¡¡¡values.length == m.values[0].length

¥¯¡¡values[0].length != m.values.length ||

¡¡¡¡values.length != m.values[0].length

b¡¤d ¤Ë´Ø¤¹¤ë²òÅú·²

¥¢¡¡return (Matrix)null

¥¤¡¡return new Matrix()

¥¦¡¡return new Matrix(result)

¥¨¡¡return new String(rep)

¥ª¡¡return rep

¥«¡¡return rep.getBytes()

¥­¡¡return result

¥¯¡¡System.out.println(rep)


Ìä13 ¡¡¼¡¤Î¥¢¥»¥ó¥Ö¥é¥×¥í¥°¥é¥à¤ÎÀâÌÀµÚ¤Ó¥×¥í¥°¥é¥à¤òÆɤó¤Ç¡¤ÀßÌä 1 ¡Á 3 ¤ËÅú¤¨¤è¡£

¡Ì¥×¥í¥°¥é¥à¤ÎÀâÌÀ¡Í

Éû¥×¥í¥°¥é¥à BINS ¤Ï¡¤¼¡¤Ë¼¨¤¹¤è¤¦¤Ë¡¤¥Ó¥Ã¥ÈÎó 1 ¤Îº¸Ã¼¤ÎÉôʬ¥Ó¥Ã¥ÈÎó A ¤ò¥Ó¥Ã¥ÈÎó 2 ¤Î»ØÄꤵ¤ì¤¿°ÌÃÖ¤ËÁÞÆþ¤¹¤ë¡£ m¡¤n ¤Ï¤½¤ì¤¾¤ì¥Ó¥Ã¥È¿ô¤òɽ¤¹¡£

(1)¡¡¥Ó¥Ã¥ÈÎó 1 ¤È¥Ó¥Ã¥ÈÎó 2 ¤ÎŤµ¤Ï¡¤¤½¤ì¤¾¤ì 16 ¥Ó¥Ã¥È¡Ê1 ¸ì¡Ë¤È¤¹¤ë¡£

(2)¡¡GR0 ¡Á GR3¤Ë¤Ï¡¤¤½¤ì¤¾¤ì¼¡¤ÎÆâÍƤ¬ÀßÄꤵ¤ì¤Æ¡¤¼ç¥×¥í¥°¥é¥à¤«¤éÅϤµ¤ì¤ë¡£

GR0¡§¥Ó¥Ã¥ÈÎó 1

GR1¡§¥Ó¥Ã¥ÈÎó 2 ¤¬³ÊǼ¤µ¤ì¤Æ¤¤¤ë¸ì¤Î¥¢¥É¥ì¥¹

GR2¡§m

GR3¡§n

(3)¡¡0 ¡å m ¡ã 16¡¤0 ¡å n ¡ã 16¡¤m ¡Ü n ¡å 16 ¤È¤¹¤ë¡£

(4)¡¡Éôʬ¥Ó¥Ã¥ÈÎó C ¤Î¤Ï¤ß½Ð¤·¤¿Éôʬ¤Ï¼Î¤Æ¤é¤ì¤ë¡£

(5)¡¡Éû¥×¥í¥°¥é¥à¤«¤éÌá¤ë¤È¤­¡¤ÈÆÍѥ쥸¥¹¥¿ GR1 ¡Á GR7 ¤ÎÆâÍƤϸµ¤ËÌ᤹¡£

¡Ì¥×¥í¥°¥é¥à¡Í


¡Ê¹ÔÈÖ¹æ¡Ë
 1  BINS  START
 2        RPUSH
 3        LD      GR4,GR2
 4        ADDA    GR4,GR3        ; GR4 ¢«  m ¡Ü n
 5        LAD     GR5,16
 6        SUBA    GR5,GR2        ; GR5 ¢« 16 ¡Ý m
 7        LAD     GR6,16
 8        SUBA    GR6,GR4        ; GR6 ¢« 16¡Ý¡Êm ¡Ü n¡Ë
 9        LAD     GR2,16
10        SUBA    GR2,GR3        ; GR2 ¢« 16 ¡Ý n
11        LD      GR7,0,GR1      ; GR7 ¢« ¥Ó¥Ã¥ÈÎó 2
12        SRL     GR7,0,GR2      
13        SLL     GR7,0,GR2      ; Éôʬ¥Ó¥Ã¥ÈÎó C ¤ò¤¹¤Ù¤Æ 0 ¤Ë¤¹¤ë
14        SRL     GR0,0,GR5      
15         ; Éôʬ¥Ó¥Ã¥ÈÎó A ¤òÁÞÆþ°ÌÃ֤˰ÜÆ°
16        OR      GR7,GR0
17        LD      GR2,0,GR1      ; ¥Ó¥Ã¥ÈÎó 2 ¤Î¸µ¤ÎÆâÍÆ
18        SLL     GR2,0,GR3      
19         ; Éôʬ¥Ó¥Ã¥ÈÎó C ¤ò·ë²Ì¤Î°ÌÃ֤˰ÜÆ°
20        OR      GR7,GR2
21        ST      GR7,0,GR1
22        RPOP
23        RET
24        END

ÀßÌ䣱¡¡¥×¥í¥°¥é¥àÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

²òÅú·²

¥¢¡¡SLL GR0,0,GR2¡¡¡¡¡¡¡¡¥¤¡¡SLL GR0,0,GR4

¥¦¡¡SLL GR0,0,GR5¡¡¡¡¡¡¡¡¥¨¡¡SLL GR0,0,GR6

¥ª¡¡SRL GR2,0,GR3¡¡¡¡¡¡¡¡¥«¡¡SRL GR2,0,GR4

¥­¡¡SRL GR2,0,GR5¡¡¡¡¡¡¡¡¥¯¡¡SRL GR2,0,GR6


ÀßÌ䣲¡¡¼¡¤Îµ­½ÒÃæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤ÎÃ椫¤éÁª¤Ù¡£

¼ç¥×¥í¥°¥é¥à¤«¤éÅϤµ¤ì¤¿¥Ó¥Ã¥ÈÎó 1¡¤¥Ó¥Ã¥ÈÎó 2¡¤m¡¤n ¤ÎÆâÍƤ¬¼¡¤Î¤È¤ª¤ê¤Î¤È¤­¡¤¹ÔÈÖ¹æ 16 ¤Î OR Ì¿Îá¼Â¹ÔľÁ°¤Î GR7 ¤ÎÆâÍÆ¤Ï ¤Ç¡¤ GR0 ¤ÎÆâÍÆ¤Ï ¤Ç¤¢¤ë¡£


ÀßÌ䣳¡¡Éû¥×¥í¥°¥é¥à BINS ¤ò»ÈÍѤ·¤Æ¡¤¼¡¤Ë¼¨¤¹¤è¤¦¤Ë¡¤Éôʬ¥Ó¥Ã¥ÈÎó A ¤òŤµ¤¬ 32 ¥Ó¥Ã¥È¡Ê2 ¸ì¡Ë¤Î¥Ó¥Ã¥ÈÎó 2 ¤ËÁÞÆþ¤¹¤ëÉû¥×¥í¥°¥é¥à BINSL ¤òºîÀ®¤·¤¿¡£

¼ç¥×¥í¥°¥é¥à¤«¤éÅϤµ¤ì¤ë¥ì¥¸¥¹¥¿¤ÎÆâÍƤϡ¤¼¡¤Î¤È¤ª¤ê¤È¤¹¤ë¡£

GR0¡§¥Ó¥Ã¥ÈÎó 1

GR1¡§¥Ó¥Ã¥ÈÎó 2 ¤¬³ÊǼ¤µ¤ì¤Æ¤¤¤ëÎΰè¤ÎÀèƬ¥¢¥É¥ì¥¹

GR2¡§m

GR3¡§n

¤Ê¤ª¡¤0 ¡å m ¡ã 16¡¤0 ¡å n ¡ã32¡¤m ¡Ü n ¡å 32 ¤È¤¹¤ë¡£

Éû¥×¥í¥°¥é¥à BINSL Ãæ¤Î ¤ËÆþ¤ì¤ëÀµ¤·¤¤Åú¤¨¤ò¡¤²òÅú·²¤Î

Ã椫¤éÁª¤Ù¡£


BINSL  START
       RPUSH
       CPA     GR3,=15         ; n ¡æ 16 ?
       JPL     RIGHT           ; YES
       LD      GR7,0,GR1       ; ¥Ó¥Ã¥ÈÎó 2 ¤ÎÂè 1 ¸ì¤òÂàÈò
       LD      GR5,GR2
       ADDA    GR5,GR3         ; GR5 ¢« m ¡Ü n
       CPA     GR5,=17         ; m ¡Ü n ¡å 16 ¡©
       JMI     LEFT            ; YES
       LAD     GR2,16
       SUBA    GR2,GR3
       LD      GR6,GR0         ; Éôʬ¥Ó¥Ã¥ÈÎó A ¤Î¤Ï¤ß½Ð¤¹Éôʬ¤ò
       SLL     GR6,0,GR2       ; ¡¡¡¡º¸Ã¼¤Ë´ó¤»¤Æ¥Ó¥Ã¥ÈÎó 1 ¤òÂàÈò
LEFT   CALL    BINS            ; Éôʬ¥Ó¥Ã¥ÈÎó A ¤ò¥Ó¥Ã¥ÈÎó 2 ¤ËÁÞÆþ
       LAD     GR1,1,GR1       ; GR1 ¢« ¥Ó¥Ã¥ÈÎó 2 ¤ÎÂè 2 ¸ì¤Î¥¢¥É¥ì¥¹
       LAD     GR3,16
       
       LD      GR0,GR7         ; ¥Ó¥Ã¥ÈÎó 2 ¤ÎÂè 1 ¸ì¤Î¤Ï¤ß½Ð¤·¤¿Éôʬ¤ò
       SLL     GR0,0,GR3       ; ¡¡¡¡º¸Ã¼¤Ë´ó¤»¤ë
       LAD     GR3,0           ; n ¢« 0
       CALL    BINS            ; ¤Ï¤ß½Ð¤·¤¿¥Ó¥Ã¥ÈÎó¤òÂè 2 ¸ì¤ËÁÞÆþ
       LD      GR2,GR5         
       SUBA    GR2,=16         ; m ¢«¡Êm ¡Ü n¡Ë¡Ý 16
       JMI     FIN
       LD      GR0,GR6         ; Éôʬ¥Ó¥Ã¥ÈÎó A ¤Î¤Ï¤ß½Ð¤¹Éôʬ¤ò
       CALL    BINS            ; ¡¡¡¡Âè 2 ¸ì¤ËÁÞÆþ
       JUMP    FIN
RIGHT  
       LAD     GR1,1,GR1       ; GR1 ¢« ¥Ó¥Ã¥ÈÎó 2 ¤ÎÂè 2 ¸ì¤Î¥¢¥É¥ì¥¹
       CALL    BINS
FIN    RPOP
       RET
       END

²òÅú·²

¥¢¡¡ADDA GR2,GR3¡¡¡¡¡¡¡¡¥¤¡¡ADDA GR3,GR2

¥¦¡¡LAD GR2,-16,GR3¡¡¡¡¡¡¡¡¥¨¡¡LAD GR2,-16,GR5

¥ª¡¡LAD GR3,-16,GR3¡¡¡¡¡¡¡¡¥«¡¡LAD GR3,-16,GR5

¥­¡¡SUBA GR2,GR3¡¡¡¡¡¡¡¡¥¯¡¡SUBA GR3,GR2