next up previous contents index
Next: main ´Ø¿ô¤ÎºîÀ® Up: ¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¥×¥í¥°¥é¥ß¥ó¥° Previous: ¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¥×¥í¥°¥é¥ß¥ó¥°   Contents   Index

¥¯¥é¥¹¤ÎÀß·×

Âè 2 ¹Ô¤Î class ¤«¤é»Ï¤Þ¤êÂè 10 ¹Ô¤Î }; ¤Ë»ê¤ë¹Ô¤¬¡¢¥¯¥é¥¹¤ÎÄêµÁ ¤òɽ¤·¤Æ¤¤¤Þ¤¹¡£C++ ¤Î¥¯¥é¥¹¤Ï¡¢¥ª¥Ö¥¸¥§¥¯¥È¤ÎÆ°ºî¤ËɬÍפʥá¥ó¥ÐÊÑ ¿ô¤È¡¢¤½¤Î¥ª¥Ö¥¸¥§¥¯¥È¤òÁàºî¤¹¤ë¤¿¤á¤Î¥á¥ó¥Ð´Ø¿ô¤ò°ìÂΤˤ·¤Æ¹½À®¤µ¤ì¡¢°ì È̤˰ʲ¼¤Î¤è¤¦¤Ê¹½Â¤¤ò¤·¤Æ¤¤¤Þ¤¹¡£

\begin{figure*}\begin{small}
\begin{screen}
\begin{verbatim}class ¥¯¥é¥¹Ì¾ {
...
...¤òÆþ¤ì¤ë)
};\end{verbatim}
\end{screen}\end{small}\vspace{-1.5em}
\end{figure*}

class ¤Î¤¢¤È¤ËÀß·×¼Ô¤¬Ì¿Ì¾¤·¤¿¥¯¥é¥¹Ì¾¡Ê¤³¤³¤Ç¤Ï CCalc¡Ë¤ò½ñ¤­¤Þ¤¹¡£¥¯¥é¥¹ ¤Î̾Á°¤ÏÈæ³ÓŪ¼«Í³¤Ë¤Ä¤±¤é¤ì¤Þ¤¹¤¬¡¢Ëܽñ¤Ç¤Ï¥¯¥é¥¹¤Ç¤¢¤ë¤³¤È¤ò¤ï¤«¤ê¤ä¤¹ ¤¯¤¹¤ë¤¿¤á¤Ë¡¢Ä̾ï¤Î¥¯¥é¥¹³µÇ°¤Ë C ¤ò¤Ä¤±¤¿¤â¤Î¤ò»È¤¦¤è¤¦¤Ë¤·¤Þ¤·¤¿¡£ ¤³¤³¤Ç¤ÏÅÅÂî¤Î¥¯¥é¥¹¤Ç¤¹¤Î¤Ç CCalc ¤È¤¤¤¦Ì¾Á°¤ò¤Ä¤±¤¿¤ï¤±¤Ç¤¹¡£

¥¯¥é¥¹Ì¾¤Î¸å¤í¤Î { ¤«¤é } ¤Þ¤Ç¤¬¡¢¤½¤Î¥¯¥é¥¹¤Î¶ñÂÎŪ¤Ê¹½À® ¤òµ­½Ò¤¹¤ëÉôʬ¤Ç¤¹¡£¤Þ¤¿¡¢¥¯¥é¥¹¤Îµ­½Ò¤Î½ª¤ê¤Ë¤Ïɬ¤º¶èÀڤ국¹æ¡Ö;¡×¤ò½ñ¤­ ¤Þ¤¹¡£ÉáÄÌ } ¤Ç½ªÎ»¤¹¤ëʸ¤¬ÂçÉôʬ¤Ç¤¹¤¬¡¢¥¯¥é¥¹¤ÎÄêµÁ¤ÏÎ㳰Ū ¤Ë }; ¤Ç½ªÎ»¤¹¤ë¤Î¤Ç½½Ê¬Ãí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£

{ } Æâ¤ÏÄ̾ï¤ÏÆó¤Ä¤ÎÉôʬ¤«¤é¤Ê¤ê¤Þ¤¹¡£ÅÅÂî¤ÎÍøÍѼԤ¬Ä¾ÀÜ°·¤¦¤³¤È ¤Î¤Ç¤­¤Ê¤¤Èó¸ø³«Éô¤È¡¢ÍøÍѼԤËÂФ¹¤ë ¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤È¤·¤Æµ¡Ç½¤¹¤ë¸ø³«Éô¤Ç ¤¹¡£¥¯¥é¥¹¤Îµ­½ÒÉô¤Ç private: ¤¬¸½¤ì¤ë¤È¡¢ ¤½¤ì°Ê¹ß¤ÎÉôʬ¤ÏÈó¸ø³«¤Ç¤¢¤ë ¤È¸«¤Ê¤µ¤ì¤Þ¤¹¡£¤·¤«¤·¡¢¥¯¥é¥¹¤ÎÆâÉô¤Îµ­½Ò¤Ï¡¢²¿¤â¤¤¤ï¤Ê¤±¤ì¤ÐÈó¸ø³«¤Ç¤¢ ¤ë¤ÈÌ󫤵¤ì¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢private: ¤Ï¿¤¯¤Î¾ì¹ç¾Êά¤µ¤ì¤Þ¤¹¡£°ìÊý¡¢¸ø³« Éô¤Ï public: ¤Èµ­ºÜ¤·¤Ê¤¤¤È¸ø³«¤È¤Ï¸«¤Ê¤µ¤ì¤Þ¤»¤ó¤Î¤ÇÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£



Èó¸ø³«¥á¥ó¥ÐÊÑ¿ôÉô¤ÎºîÀ®

¼ÂºÝ¤ÎÅÅÂî¤Ç¤â¥ì¥¸¥¹¥¿¤ÏÍøÍѼԤ«¤éľÀܸ«¤¿¤ê¡¢Êѹ¹¤·¤¿¤ê¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Þ ¤»¤ó¡£ÍøÍѼԤÏÍÑ°Õ¤µ¤ì¤¿¥­¡¼Áàºî¤Ë¤è¤Ã¤Æ¤Î¤ß¡¢¤½¤ÎÆâÍƤò¼è¤ê°·¤¦¤³¤È¤¬¤Ç ¤­¤Þ¤¹¡£¤³¤Î°ÕÌ£¤Ç¡¢¥ì¥¸¥¹¥¿¤ÏÅÅÂî¤Ë¤È¤Ã¤ÆÈó¸ø³«¤Ç¤¢¤ë¤È¤¤¤¨¤Þ¤¹¡£°ìÊý¡¢ ¥­¡¼Áàºî¤ÎÊý¤ÏÍøÍѼԤÀ¤ì¤Ç¤â¤¬¼«Í³¤Ë°·¤¨¤Þ¤¹¡£¸À¤¤´¹¤¨¤ì¤Ð¤À¤ì¤Ë¤Ç¤â¸ø ³«¤µ¤ì¤Æ¤ª¤ê¡¢¸ø³«¤È¤¤¤¨¤Þ¤¹¡£¤½¤³¤Ç¡¢¥ì¥¸¥¹¥¿¤ÏÈó¸ø³«Éô¤Ë¡¢¥­¡¼Áàºî¤Ï¸ø ³«Éô¤Ë°¤¹¤È¹Í¤¨¤Þ¤¹¡£¤³¤Î¤è¤¦¤Ë¡¢ÉáÄ̤ϥá¥ó¥ÐÊÑ¿ô¤ÏÈó¸ø³«Éô¤Ë¡¢¥á¥ó¥Ð ´Ø¿ô¤Ï¸ø³«Éô¤ËÃÖ¤­¤Þ¤¹¡£¤Þ¤¿¡¢ÆâÉô¤À¤±¤Ç¤è¤¯»È¤¦¥á¥ó¥Ð´Ø¿ô¤¬¤¢¤ë¾ì¹ç¤Ï¡¢ Èó¸ø³«Éô¤ËÃÖ¤­¤Þ¤¹¡£

Èó¸ø³«¤Ç¤¢¤ë¥ì¥¸¥¹¥¿¤ÎÆâÍƤò r ¤È¤¤¤¦¡ÖÊÑ¿ô¡×¤Çɽ¤·¤Þ¤·¤ç¤¦¡£¥ì¥¸¥¹¥¿¤Î ¤è¤¦¤ËǤ°Õ¤ÎÃͤòÊÝ»ý¤¹¤ë¤³¤È¤Î¤Ç¤­¤ëµ­²±Í×ÁǤòÊÑ¿ô¤È¤¤¤¤¤Þ¤¹¡£¿ô³Ø¤Ç»È¤ï ¤ì¤ëÊÑ¿ô¤È¤Ï¸·Ì©¤Ë¤Ï°Û¤Ê¤ê¤Þ¤¹¤¬¡¢·×»»¼°¤ÎÃæ¤Ç¤Ï»÷¤¿¤è¤¦¤Ê»È¤ï¤ìÊý¤ò¤·¤Þ ¤¹¡£ÊÑ¿ô¤ò»È¤¦¤Ë¤Ï¡¢¤½¤ÎÊÑ¿ô¤ÎÀ­¼Á¤òɽ¤¹¡Ö¥Ç¡¼¥¿·¿¡×¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤ê ¤Þ¤»¤ó¡£¤³¤³¤Ç¤Ï¥ì¥¸¥¹¥¿¤ÏÀ°¿ô¤À¤±¤òµ­²±¤Ç¤­¤ë¤È²¾Äꤷ¤Þ¤·¤ç¤¦¡£r ¤¬À°¿ô·¿¡Êinteger type¡Ë¤ÎÊÑ¿ô¤Ç¤¢¤ë¤³¤È ¤òÀë¸À¤¹¤ë¤Ë¤Ï¡¢Âè 3 ¹Ô¤Î¤è¤¦¤Ë int r; ¤È½ñ¤­¤Þ¤¹¡£À°¿ô·¿¤Î¤è¤¦¤Ë¤è¤¯»È ¤ï¤ì¤ë¥Ç¡¼¥¿·¿¤Ï¡¢¤¢¤é¤«¤¸¤áÁȤ߹þ¤Þ¤ì¤Æ¤ª¤ê¡¢¤¢¤È¤Î¾Ï¤Ç½Ò¤Ù¤ëÊ£¹ç¥Ç¡¼¥¿·¿ ¤Î´ðËܤȤʤë¥Ç¡¼¥¿·¿¤Î°ì¤Ä¤Ê¤Î¤Ç¡¢¡Ö´ðËܥǡ¼¥¿·¿ ¡×¤È¤¤¤¤¤Þ¤¹¡£ °ìÈ̤ËÊÑ¿ôÀë¸À¤Ï¼¡¤Î·Á¤Çɽ¤µ¤ì¡¢ ½ª¤ï¤ê¤Ë¤Ï¶èÀڤ국¹æ¡Ö;¡×¤¬É¬ÍפǤ¹¡£

\begin{figure*}\begin{small}
\begin{screen}
\begin{verbatim}·¿Ì¾ ÊÑ¿ô̾;\end{verbatim}
\end{screen}\end{small}\vspace{-1.5em}
\end{figure*}



¸ø³«Éô¤Î¥á¥ó¥Ð´Ø¿ô¤ÎºîÀ®

Âè 4 ¹Ô¤Î¤è¤¦¤Ë public: ¤¬¸½¤ì¤ë¤È¡¢¤½¤ì°Ê¹ß¤ÎÉôʬ¤Ï¸ø³«¤Ç¤¢¤ë¤È¸«¤Ê¤µ ¤ì¤Þ¤¹¡£¸ø³«Éô¤Ë¤Ï¥¯¥é¥¹ CCalc ¤Î¥á¥ó¥Ð´Ø¿ô¡¢¤Ä¤Þ¤êÅÅÂî¤ËÍê¤ß¤¿¤¤»Å»ö ¤òµ­½Ò¤·¤Þ¤¹¡£C ¤ä C++ ¤Î´Ø¿ô¤Ï¡¢ ¿ô³Ø¤Î´Ø¿ô¤È¤Ï¤ä¤ä°Û¤Ê¤ë³µÇ°¤Ç¤¹¤¬¡¢¤ä¤Ï¤ê $y=f(x)$ ¤Î¤è¤¦¤Ë¿ô³Ø¤Î´Ø¿ô¤È »÷¤¿¤è¤¦¤Ê»È¤ï¤ìÊý¤ò¤·¤Þ¤¹¡£¤Ä¤Þ¤ê $x$ ¤òÍ¿¤¨¤ë¤È $f(x)$ ¤¬¤¢¤ëÃͤò¤È¤ê ¤Þ¤¹¡£C ¤Ç¤Ï¾å¼°¤Î $f$ ¤ò´Ø¿ô̾¡¢$x$ ¤ò°ú¿ô¡¢$f(x)$ ¤ò´Ø¿ô¸Æ½Ð¤·¡¢ $f(x)$ ¤Î·×»»·ë²Ì¤òÌáÃͤȤè¤Ó¤Þ¤¹¡£

¤¢¤ë¥á¥ó¥Ð´Ø¿ô¤¬¤É¤Î¤è¤¦¤ÊƯ¤­¤ò¤¹¤ë¤«¤Îµ­½Ò¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ê·Á¼°¤Ç¡¢¥¯¥é ¥¹Æâ¤Ë¤½¤ÎÄêµÁ¤ò½ñ¤¯¤³¤È¤¬²Äǽ¤Ç¤¹¡£¤³¤Î¤è¤¦¤Ë¡¢¥¯¥é¥¹Æâ¤ÇÄêµÁ¤µ¤ì¤ë´Ø¿ô ¤ò¥¤¥ó¥é¥¤¥ó´Ø¿ô¤È¤è¤Ó¤Þ¤¹¡£´Ø¿ô¤ÎÄêµÁ¤¬¤â¤Ã¤ÈŤ¯¤Ê¤Ã¤Æ¤¯¤ë¤È¡¢¥¯¥é¥¹¤Î ÄêµÁ¤È¤ÏÊ̤˽ñ¤¯¤Î¤¬ÉáÄ̤ˤʤäƤ­¤Þ¤¹¤¬¡¢¤½¤ì¤Ë ¤Ä¤¤¤Æ¤Ï [*] ¾Ï°Ê¸å¤ËÀâÌÀ¤· ¤Þ¤¹¡£ÄêµÁ¤ò¥¤¥ó¥é¥¤¥ó²½¤¹¤ë¤«¤É¤¦¤«¤Ï¡¢¤ª¤ª¤è¤½ÄêµÁ¤¬ 1 ¹Ô¤Ë¼ý¤Þ¤ë¤«¤É ¤¦¤«¤Ç·è¤á¤Æ¤¯¤À¤µ¤¤¡£

\begin{figure*}\begin{small}
\begin{screen}
\begin{verbatim}ÌáÃͤη¿ ´Ø¿ô̾(²...
...ýÆâÍƤε­½Ò }\end{verbatim}
\end{screen}\end{small}\vspace{-1.5em}
\end{figure*}

´Ø¿ôÄêµÁ¤Ç»È¤ï¤ì¤ë°ú¿ô¤Ï²¾°ú¿ô¤È¤è¤Ð¤ì¤Þ¤¹¡£°ìÊý¡¢´Ø¿ô¤Î¸Æ½Ð¤·Â¦¤Ç»ØÄꤹ ¤ë°ú¿ô¤ò¼Â°ú¿ô¤È¤è¤Ó¤Þ¤¹¡£

Âè 5 - 9 ¹Ô¤Ë¼¨¤·¤¿¸ø³«Éô¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ê¥á¥ó¥Ð´Ø¿ô¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤é¤Î¥á¥ó¥Ð´Ø¿ô¤Ï¡¢Æ±¤¸¥¯¥é¥¹¤Î¥á¥ó¥ÐÊÑ¿ô¤Ç¤¢¤ë r ¤ò¼«Í³¤ËÆɤ߽ñ¤­ ¡Ê¥¢¥¯¥»¥¹¡Ë¤¹¤ë¤³¤È¤¬µö¤µ¤ì¤Æ¤ª¤ê¡¢¤½¤Î¶ñÂÎŪ¤ÊÆ°ºî¤¬³Æ¹Ô¤Î { ¤«¤é } ¤ÎÉôʬ¤Ëµ­½Ò¤µ¤ì¤Þ¤¹¡£

    void Clr() {r = 0;}                   //  5) ¥ì¥¸¥¹¥¿¤ò¥¼¥í¥¯¥ê¥¢
    void Set(int x) {r = x;}              //  6) ¥ì¥¸¥¹¥¿¤ËÃͤòÀßÄê
    void Add(int x) {r += x;}             //  7) ¥ì¥¸¥¹¥¿¤ÎÃÍ¤Ë x ¤ò²Ã¤¨¤ë
    void Sub(int x) {r -= x;}             //  8) ¥ì¥¸¥¹¥¿¤ÎÃÍ¤Ë x ¤ò¸º¤º¤ë
    int Show() {return r;}                //  9) ¥ì¥¸¥¹¥¿¤ÎÃͤòÄÌÃΤ¹¤ë

Ä̾ï¤Î´Ø¿ô¤Ï $y=f(x)$ ¤Î¤è¤¦¤Ë¡¢¤¤¤¯¤Ä¤«¤Î²¾°ú¿ô¤ÈÌáÃͤò¤â¤Á¤Þ¤¹¤¬¡¢¤³ ¤³¤Ë¼¨¤·¤¿´Ø¿ô¤Ï¤¿¤Þ¤¿¤Þ¡¢¤¤¤º¤ì¤â¤É¤Á¤é¤«¤¬·ç¤±¤Æ¤¤¤Þ¤¹¡£¤Þ¤º¡¢Âè 9 ¹Ô ¤Î´Ø¿ô Show ¤ò¸«¤Æ¤¯¤À¤µ¤¤¡£¤³¤Î´Ø¿ô¤Ï²¾°ú¿ô¤¬¤¢¤ê¤Þ¤»¤ó¤¬¡¢int ·¿¤ÎÃͤòÌ᤹´Ø ¿ô¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤¤¤ï¤Ð $y=f( )$ ¤Î¤è¤¦¤Ê´Ø¿ô¤Ê¤Î¤Ç¤¹¡£¿ô³Ø¤Î´Ø¿ô¤Ç¤¢ ¤ë¤È¡¢¤³¤ì¤Ï¤¤¤Ä¤â°ìÄêÃͤòÌ᤹¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¤¬¡¢C ¤Ç¤Ï¡¢Èó¸ø³«Éô¤Ë ±£¤µ¤ì¤¿ÊÑ¿ô¤Î±Æ¶Á¤Ê¤É¤Ç°ìÄêÃͤòÌ᤹¤È¤Ï¸Â¤ê¤Þ¤»¤ó¡£¤³¤Î¾ì¹ç Show ¤Ï¡¢ ¤½¤Î¤È¤­¤Î¥ì¥¸¥¹¥¿¤ÎÃͤ½¤Î¤â¤Î¤òÊÖ¤·¤Þ¤¹¡£

¼¡¤Ë¡¢Clr¡¢Set¡¢Add¡¢Sub ¤ò¸«¤Æ¤¯¤À¤µ¤¤¡£¤³¤ì¤é¤Î´Ø¿ô¤ÎÌáÃÍ¤Ï void ¤Ë¤Ê¤Ã ¤Æ¤¤¤Þ¤¹¡£ÉáÄ̤δؿô $y=f(x)$ ¤È°Û¤Ê¤ê¡¢void ¤È¤¤¤¦¥Ç¡¼¥¿·¿¤òÌáÃͤη¿¤È ¤·¤Æ»È¤¦´Ø¿ô¤Ï¡¢ÌáÃͤ¬¶õ¡¢¤Ä¤Þ¤ê¥ª¥Ö¥¸¥§¥¯¥È¤ÎÍøÍѼԤ˲¿¤âÃͤòÌᤵ¤Ê¤¤¤³ ¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£¤³¤³¤Ç¤Ï¡¢¤¹¤Ù¤Æ¤Î¥á¥ó¥Ð´Ø¿ô¤¬¥ì¥¸¥¹¥¿¤ÎÃͤËÂФ·¤ÆÊѹ¹ ¤äɽ¼¨Áàºî¤ò¹Ô¤¦¤Î¤ß¤Ç¡¢¤½¤Î·ë²Ì¤¬ÍøÍѼԤËÌᤵ¤ì¤ëɬÍפ¬¤¢¤ê¤Þ¤»¤ó ¤Î¤Ç void¡Ê¶õ¤Î°ÕÌ£¡Ë¤ò»È¤¤¤Þ¤¹¡£¤Ê¤ª¡¢void ¤Ï Show ¤Ê¤É¤Î¤è¤¦¤Ë¡¢°ú¿ô¤¬¤Ê¤¤ ¾ì¹ç¡¢°ú¿ô¤ÎÂå¤ï¤ê¤Ë int Show(void) ¤È½ñ¤¤¤ÆÍøÍѤ¹¤ë¤³¤È¤â¤¢¤ê¤Þ¤¹¤¬¡¢²¾ °ú¿ôÍó¤Î void ¤Ï¾Ê¤«¤ì¤ë¤³¤È¤¬Â¿¤¯¡¢Ëܽñ¤Ç¤â¤¹¤Ù¤Æ¾Ê¤«¤ì¤Æ¤¤¤Þ¤¹¡£

¤³¤ì¤é¤Î´Ø¿ô¤ÎÃæ¤Ç¡¢Set¡¢Add¡¢Sub ¤Ï³ç¸Ì¤ÎÃæ¡¢¤Ä¤Þ¤ê²¾°ú¿ô¤¬ int x ¤È¤Ê¤Ã ¤Æ¤ª¤ê¡¢¤¿¤À°ì¤Ä¤Î int ·¿¤Î°ú¿ô x ¤ò¤â¤Ä¤³¤È¤¬¤ï¤«¤ê¤Þ¤¹¡£¤³¤ì¤é¤Î´Ø¿ô¤Ï °ú¿ô x ¤òÈï±é»»¿ô¤È¤·¤Æ¡¢¥ì¥¸¥¹¥¿¤ËÃͤòÂåÆþ¤·¤¿¤ê¥ì¥¸¥¹¥¿¤ÎÃͤ˲øº»» ¤ò¹Ô¤¤¤Þ¤¹¡£²¾°ú¿ô¤ÎÃͤϤ³¤ì¤é¤Î¥á¥ó¥Ð´Ø¿ô¤¬¼ÂºÝ¤Ë¸Æ¤Ó½Ð¤µ¤ì¤Æ»È¤ï¤ì¤ë ¤È¤­¤Ë¡¢¶ñÂÎŪ¤ÊÃͤ¬Í¿¤¨¤é¤ì¤Þ¤¹¡£

Âè 5 ¹Ô¤Î Clr ¤Ï²¿¤È²¾°ú¿ô¤âÌáÃͤâ¤â¤Á¤Þ¤»¤ó¡£¤·¤«¤·¡¢¥ì¥¸¥¹¥¿¤ò 0 ¤Ë¤¹ ¤ë¤È¤¤¤¦Î©ÇɤʻŻö¤ò¤·¤Æ¤¤¤Þ¤¹¡£¤³¤Î¤è¤¦¤Ë¡¢°ì¸«¸Æ½Ð¤·Â¦¤Ë´Ø·¸¤Ê¤¤¤è¤¦¤Ë ¸«¤¨¤Æ½ÅÍפʻŻö¤ò¤¹¤ë´Ø¿ô¤¬¤¢¤ê¤Þ¤¹¡£

´Ø¿ô̾¤Ë³¤¯ { ¤«¤é } ¤Ëµ­½Ò¤µ¤ì¤ë´Ø¿ô¤Î½èÍýÆâÍƤε­½Ò¤òÀâ ÌÀ¤·¤Þ¤¹¡£{...} Æâ¤ò´Ø¿ô¥Ö¥í¥Ã¥¯ ¤È¤è¤Ó¤Þ¤¹¡£ ´Ø¿ô¥Ö¥í¥Ã¥¯Æâ¤Ë¤Ï¡¢Ê¸¤òʤ٤ޤ¹¡£Ê¸¤È¤Ï¡¢ ¥×¥í¥°¥é¥ß¥ó¥°¸À¸ì¤ËÍÑ°Õ¤µ¤ì¤¿·×»»µ¡¤Ø¤ÎÌ¿Îá¤Î¤³¤È¤Ç¤¹¡£Ê¸¤Ë¤ÏÂçÊ̤·¤ÆÄê µÁʸ¤ÈÀë¸Àʸ¤È¼Â¹Ôʸ¤¬¤¢¤ê¤Þ¤¹¡£ÄêµÁʸ¤Ï ¥¯¥é¥¹¤ä´Ø¿ô¤¬¤É¤Î¤è¤¦¤Êʸ¤Ç¹½À®¤µ¤ì¤Æ¤¤¤ë¤«¤ò½ñ¤¤¤¿¤â¤Î¤Ç¤¹¡£Àë¸À ʸ¤ÏÊÑ¿ô¤Ê¤É¤¬¤É¤Î¤è¤¦¤Ê·¿¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤«¤ò¼¨ ¤¹¤â¤Î¤Ç¤¹¡£¤½¤Î°ÕÌ£¤Ç·¿Àë¸À¤È¤â¤¤¤ï¤ì¤Þ¤¹¡£¼Â¹Ôʸ ¤Ë¤Ï ÌÜŪ¤Ë¤è¤Ã¤ÆÍÍ¡¹¤Ê¤â¤Î¤¬¤¢¤ê¤Þ¤¹¤¬¡¢¤³¤³¤Ç»È¤ï¤ì¤Æ¤¤¤ë¤Î ¤Ï¤¤¤¯¤Ä¤«¤ÎÂåÆþʸ¤Ç¤¹¡£

¤Þ¤º¡¢ºÇ½é¤Î»Í¤Ä¤Î¥á¥ó¥Ð´Ø¿ô¤Î´Ø¿ô¥Ö¥í¥Ã¥¯Æâ¤ò¸«¤Æ¤ß¤Þ¤·¤ç¤¦¡£¤³¤³¤Ç¤Ï¡¢ ¤¤¤¯¤Ä¤«¤Î·Á¼°¤ÎÂåÆþʸ¤¬µ­½Ò¤µ¤ì¤Æ¤¤ ¤Þ¤¹¡£ÂåÆþʸ¤Ï°Ê²¼¤Î·Á¼°¤Çµ­½Ò¤µ¤ì¤Þ¤¹¡£

\begin{figure*}\begin{small}
\begin{screen}
\begin{verbatim}ÊÑ¿ô ÂåÆþ±é»»»Ò ÀßÄꤹ¤ëÃÍ\end{verbatim}
\end{screen}\end{small}\vspace{-1.5em}
\end{figure*}

¤³¤Îʸ¤Ï¡¢º¸ÊÕ¤ÎÊÑ¿ô¤Ë¡¢±¦ÊÕ¤ÎÃͤËÊѤï¤ë¤è¤¦Í×ÀÁ¤¹¤ë¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£Âå Æþ±é»»»Ò¤Ë¤ÏÄ̾ï¤ÎÂåÆþ¤À¤±¤Ç¤Ï¤Ê¤¯¡¢±¦ÊÕ¤ÎÃͤÀ¤±Áý¤¨¤Æ¤¯¤ì¤È¤«¡¢¤½¤Î¾ °Ê²¼¤Ë¼¨¤¹¤è¤¦¤Ê¼ï¡¹¤Îµ¡Ç½¤¬¤¢¤ê¤Þ¤¹¡£

C ¤Ç»È¤ï¤ì¤ëÂåÆþ±é»»»Ò ¤Ë¤Ï°Ê²¼¤Î¤â¤Î¤¬¤¢¤ê¤Þ¤¹¡£

\begin{figure*}\begin{small}
\begin{screen}
\begin{verbatim}= º¸ÊÕ¤ÎÊÑ¿ô¤Ë¡¢±...
...¤ê¤òÀßÄꤹ¤ë
\end{verbatim}
\end{screen}\end{small}\vspace{-1.5em}
\end{figure*}

¤³¤ì¤é¤ò»È¤Ã¤Æ¡¢¥ì¥¸¥¹¥¿¤ò¥¼¥í¤Ë½é´ü²½¤¹¤ë¤Ë¤Ï r = 0; ¤È¤·¤Þ¤¹¡£¤Þ¤¿¡¢ ¥ì¥¸¥¹¥¿¤Ë x ¤ò²Ã¤¨¤ë¤Ë¤Ï r += x; ¤È¤·¤Þ¤¹¡£r += x; ¤Ï r = r + x; ¤È½ñ ¤¯¤³¤È¤â¤Ç¤­¤Þ¤¹¤¬¡¢Á°¼Ô¤Î¤è¤¦¤Ëɽ¸½¤¹¤ëÊý¤¬·×»»Â®ÅÙ¤¬Á᤯¤Ê¤ë¤Î¤Ç¡¢¤³ ¤¦¤·¤¿½ñ¤­Êý¤ËÁá¤á¤Ë´·¤ì¤ë¤è¤¦ÅØÎϤ·¤Æ¤¯¤À¤µ¤¤¡£Æ±Íͤˡ¢¥ì¥¸¥¹¥¿¤«¤é x ¤ò¸º¤¸¤ë¤Ë¤Ï r -= x; ¤È¤Ê¤ê¤Þ¤¹¡£

Âè 9 ¹Ô¤Î Show ¤Ï¥ì¥¸¥¹¥¿¤ÎÆâÍƤòÄÌÃΤ¹¤ë´Ø¿ô¤Ç¤¹¤¬¡¢¤½¤Î´Ø¿ô¥Ö¥í¥Ã¥¯Ãæ ¤Ë¤Ï return r; ¤È¤¤¤¦Ê¸¤¬°ì¤Äµ­½Ò¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ï¡¢¥ì¥¸¥¹¥¿ r ¤ÎÃÍ ¤ò Show ¥á¥Ã¥»¡¼¥¸¤Î¸Æ½Ð¤·Â¦¤ËÌ᤹¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£¤³¤ì¤ò´Ø¿ô¤ÎÌá ÃͤȤ¤¤¤¤Þ¤¹¡£°ìÈ̤ˡ¢¤¢¤ë¼°¤ÎÃͤòÌáÃͤËÀßÄꤷ¤Æ´Ø ¿ô¤«¤éÌá¤ë¾ì¹ç¤Ë¤Ï¡¢¼¡¤Î·Á¤Îʸ¤òÆþ¤ì¤Þ¤¹¡£

\begin{figure*}\begin{small}
\begin{screen}
\begin{verbatim}return ¼°;\end{verbatim}
\end{screen}\end{small}\vspace{-1.5em}
\end{figure*}

main ´Ø¿ô¤Þ¤Ç¸«¤Æ¤ß¤ë¤È¡¢¥¯¥é¥¹¤Î¥á¥ó¥Ð´Ø¿ô Clr ¤È Sub ¤Ï main ´Ø¿ôÆâ¤Ç ¤â»È¤ï¤ì¤Æ¤¤¤Þ¤»¤ó¡£¤³¤ì¤é¤Ï»È¤¤¤â¤·¤Ê¤¤¤Î¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤·¤«¤·¡¢¤³ ¤ì¤Ç¤è¤¤¤Î¤Ç¤¹¡£¤³¤ÎÅÅÂî¤Î¥¯¥é¥¹¤Ï¡¢º£¤Ï­¤·»»¤Ë¤·¤«»È¤ï¤ì¤Æ¤¤¤Þ¤»¤ó¤¬¡¢ ¾­Íè°ú¤­»»¤Ë»È¤ï¤ì¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¤·¡¢¤Þ¤¿²¿¤«¤Î·×»»¤Ç¥ì¥¸¥¹¥¿¥¯¥ê¥¢¤¬ ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ÊØÍø¤Êµ¡Ç½¤Ï¤¤¤¯¤é¤¢¤Ã¤Æ¤â¤è¤¤¤Î¤Ç¤¹¡£¤Ä¤Þ¤ê¡¢¥¯¥é¥¹ ¤ÎÄêµÁ¤Ë¤¢¤¿¤Ã¤Æ¤Ï¡¢ÉÔÆÃÄê¿¿ô¤Î¥æ¡¼¥¶¤¬»È¤¦¤³¤È¤òÁ°Äó¤Ë¤·¤¿¤è¤¦¤Ê¥×¥í¥° ¥é¥ß¥ó¥°¤ò¤¹¤ëÂÖÅÙ¤¬É¬ÍפǤ¹¡£


ÌäÂê1 ¡¡ ¿Þ1.1¤Ë¼¨¤·¤¿ CCalc ¥¯¥é¥¹ ¤Ë¡¢²Ã¸º»»¤Î¥á¥ó¥Ð´Ø¿ô¤ò»²¹Í¤Ë¤·¤Æ¡¢¼¡¤Î¥á¥ó¥Ð´Ø¿ô¤òÄɲ䷤Ƥߤޤ·¤ç¤¦¡£

  1. ¥ì¥¸¥¹¥¿¤Ë¡¢°ú¿ô¤ò¾è¤º¤ë¥á¥ó¥Ð´Ø¿ô: void Mul(int)
  2. ¥ì¥¸¥¹¥¿¤Ë¡¢°ú¿ô¤Ç½ü¤·¤¿¤È¤­¤Î¾¦¡ÊÀ°¿ô¡Ë¤òÀßÄꤹ¤ë ¥á¥ó¥Ð´Ø¿ô:
    void Div(int)
  3. ¥ì¥¸¥¹¥¿¤Ë¡¢°ú¿ô¤Ç½ü¤·¤¿¤È¤­¤Î;¤ê¤òÀßÄꤹ¤ë¥á¥ó ¥Ð´Ø¿ô:
    void Mod(int)


next up previous contents index
Next: main ´Ø¿ô¤ÎºîÀ® Up: ¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¥×¥í¥°¥é¥ß¥ó¥° Previous: ¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¥×¥í¥°¥é¥ß¥ó¥°   Contents   Index
Yoichi OKABE 2006-05-20