next up previous contents index
Next: ¥×¥í¥°¥é¥à³«È¯¤Î¼ê½ç Up: ¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¥×¥í¥°¥é¥ß¥ó¥° Previous: ¥¯¥é¥¹¤ÎÀß·×   Contents   Index

main ´Ø¿ô¤ÎºîÀ®

main ´Ø¿ô¤ÎÄêµÁ¤ò²þ¤á¤Æµ­ºÜ¤·¤Þ¤¹¡£

\begin{figure*}\begin{small}
\begin{screen}
\begin{verbatim}/* main ´Ø¿ô¤ÎÄêµ...
...ô¤ÎÄêµÁ¤Î½ªÎ»\end{verbatim}
\end{screen}\end{small}\vspace{-1.5em}
\end{figure*}

Âè 12 ¹Ô¤Ë¤Ä¤¤¤Æ¤Ï¤¢¤È¤«¤éÀâÌÀ¤·¤Þ¤¹¡£Âè 13 - 22 ¹Ô¤Î main ´Ø¿ôÆâ¤Î½èÍý ¤â¡¢¥á¥ó¥Ð´Ø¿ô¤ÈƱÍͤ˴ؿô¤Î·Á¤Çµ­½Ò¤·¤Þ¤¹¡£ÅÅÂî¤ÎÍøÍѼ곤­¤Ë¤·¤¿¤¬¤Ã ¤ÆÅÅÂ¥Ö¥¸¥§¥¯¥È¤ËÂФ¹¤ë¥á¥Ã¥»¡¼¥¸¤ò½ç¤Ë½ñ¤¤¤Æ¤¤¤±¤Ð¤è¤¤¤Î¤Ç¤¹¡£

¤³¤Î¥×¥í¥°¥é¥à¤Ç¤Ï¡¢Èï²Ã¿ô¤ä²Ã¿ô¤ò¥×¥í¥°¥é¥à¤Î¼Â¹Ô»þ¤ËÆþ¤ì¤é¤ì¤ë¤è¤¦¤Ë¤· ¤Þ¤·¤¿¡£¤Þ¤¿¡¢·×»»·ë²Ì¤Î½ÐÎϤâ¥Ç¥£¥¹¥×¥ì¥¤¤Ë¡Ö1 + 2 = 3¡×¤Î¤è¤¦¤Ê·Á¼°¤Ç ɽ¼¨¤·¤Æ¤â¤é¤¦¤³¤È¤Ë¤·¤Þ¤¹¡£¥¯¥é¥¹Â¦¤Ç¤Ï¥ì¥¸¥¹¥¿¤ÎÆâÍƤ·¤«³Ð¤¨¤Æ¤¤¤Ê¤¤¤Î ¤Ç¡¢Èï²Ã¿ô¤ä²Ã¿ô¤Ï´Ø¿ô main ¦¤Çµ­²±¤·¤Æ¤ª¤­¡¢½ÐÎϤκÝÍøÍѤǤ­¤ë¤è¤¦¤Ë ¤·¤Þ¤¹¡£¤³¤Î¤¿¤á¡¢´Ø¿ô main ¤ÎÃæ¤ÇÀ°¿ô·¿¤ÎÊÑ¿ô x¡¢y ¤òÀë¸À¤·¤Þ¤¹¡£



¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤ÈÊÑ¿ôÀë¸À

CCalc ¥¯¥é¥¹¤ÏÅÅÂî¤ÎÀ­¼Á¤òɽ¤¹¥¯¥é¥¹¤Ç¤¢¤Ã¤Æ¡¢»Å»ö¤ò°ÍÍꤹ¤ë¡ÖÅÅÂ¤ó¡× ¤Î¤è¤¦¤Ê¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£¤³¤Î¤Þ¤Þ¤Ç¤Ï¡¢main ´Ø¿ô¤«¤é»ÈÍѤ¹¤ë ¤³¤È¤¬¤Ç¤­¤Ê¤¤¤Î¤Ç¤¹¡£»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¤³¤Î¥¯¥é¥¹¤ò·¿¤È¤·¤¿ÅÅÂî·¿¤Î¼ÂÂÎ¤Ç ¤¢¤ë¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤·¤Ê¤¯¤Æ¤Ï¤Ê¤ê¤Þ¤»¤ó¡£

¤¢¤ë¥¯¥é¥¹¤Î¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À® ¤¹¤ë¤Ë¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ê·Á¼°¤ÎÀë¸À¤ò¤·¤Þ¤¹¡£

\begin{figure*}\begin{small}
\begin{screen}
\begin{verbatim}¥¯¥é¥¹Ì¾ ¥ª¥Ö¥¸¥§¥¯¥È̾;\end{verbatim}
\end{screen}\end{small}\vspace{-1.5em}
\end{figure*}

¶ñÂÎŪ¤Ë¤Ï¡¢CCalc calc; ¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£¤³¤ì¤Ï¼Â¤Ï¡¢ÊÑ¿ôÀë¸À¤Ë¤Ê¤Ã¤Æ¤¤ ¤Þ¤¹¡£¤Ä¤Þ¤ê¡¢CCalc ¤È¤¤¤¦·¿Ì¾¤ò¤â¤ÄÊÑ¿ô calc ¤òÀë¸À¤·¤¿¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£ ¤³¤ÎÀë¸À¤Ë¤è¤Ã¤Æ¡¢CCalc ¤ÎÄêµÁ¤Ç¼¨¤·¤¿¤è¤¦¤ÊÊÑ¿ô¤È¥á¥ó¥Ð´Ø¿ô¤ò¤â¤Ä¥ª¥Ö¥¸¥§ ¥¯¥È¤¬À¸À®¤µ¤ì¡¢Àë¸À¤Ç»ØÄꤷ¤¿ calc ¤È¤¤¤¦Ì¾Á°¤ÇÍøÍѲÄǽ¤Ë¤Ê¤ë¤Î¤Ç¤¹¡£

Àë¸Àʸ int x, y; ¤Ï¡¢main ´Ø¿ôÃæ¤ÇÆɤ߹þ¤àÆó¤Ä¤ÎÃͤΤ¿¤á¤ËÍÑ°Õ¤¹¤ëÊÑ¿ô̾ ¤ÎÀë¸À¤Ç¤¹¡£CCalc ¤Ë¤è¤ë±é»»¤Ç°·¤¦¥Ç¡¼¥¿·¿¤Ï int ·¿¤Ë¸Â¤é¤ì¤ë¤Î¤Ç¡¢¤³¤ì ¤é¤Ï int ¤ÈÀë¸À¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤³¤ÎÀë¸À¤Ç int ·¿¤ÎÊÑ¿ô x ¤È y ¤¬ÍÑ°Õ¤µ¤ì¤Þ ¤¹¡£¤³¤ì¤Ï°Ê²¼¤Î¤è¤¦¤Ëʬ¤±¤Æ½ñ¤¤¤¿¤Î¤ÈƱ¤¸¤³¤È¤Ç¤¹¡£

    int x;
    int y;



Æþ½ÐÎÏ

¼¡¤ËÂè 16 ¹Ô¤Ç¡¢Èï²Ã¿ô¤ò¥­¡¼¥Ü¡¼¥É¤«¤é¼õ¤±¼è¤ê x ¤ËÂåÆþ¤·¤Þ¤¹¡£°ìÈÌ¤Ë¥×¥í ¥°¥é¥ß¥ó¥°¸À¸ì¤Ë¤ª¤¤¤Æ¤Ï¡¢³°Éô¤«¤é·×»»µ¡¤Ë¥Ç¡¼¥¿¤ò¼è¤ê¹þ¤à¤³¤È¤òÆþÎÏ¡¢³° Éô¤Ø·×»»µ¡¤«¤é¥Ç¡¼¥¿¤òÁ÷¤ê½Ð¤¹¤³¤È¤ò½ÐÎϤȤ¤¤¤¤Þ¤¹¡£¤Þ¤¿¡¢ÆþÎϤȽÐÎÏ¤Ë»È ÍѤµ¤ì¤ëÁõÃÖ¤òÆþ½ÐÎÏÁõÃ֤Ȥè¤Ó¤Þ¤¹¡£·×»»µ¡¤Îɸ½à¤ÎÆþÎÏÁõÃ֤ϥ­¡¼¥Ü¡¼¥É¤Ç¡¢ ¤³¤ì¤ËÂбþ¤·¤Æ cin ¤È¤¤¤¦ ¥ª¥Ö¥¸¥§¥¯¥È¤ÈÆþÎϤò¹Ô¤¦±é»»»Ò » ¤¬ÍÑ°Õ¤µ ¤ì¤Æ¤¤¤Þ¤¹¡£½ÐÎÏÁõÃ֤ϥǥ£¥¹¥×¥ì¥¤¤Ç¡¢¤³¤ÎÁõÃÖ¤ËÂбþ ¤¹¤ë cout ¤È¤¤¤¦¥ª¥Ö¥¸¥§¥¯¥È¤È¤³¤ì¤ËÂбþ¤·¤¿ ½ÐÎϤò¹Ô¤¦±é»»»Ò « ¤¬ÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

Èï²Ã¿ô¤ÎÆþÎϤˤϡ¢¤Þ¤º¥æ¡¼¥¶¤ËÆþÎϤòÂ¥¤¹Ê¸»úÎó¤ò cout « "Èï²Ã¿ô? "; ¤Ç¤â¤Ã¤Æ½ÐÎϤ·¤Þ¤¹¡£¤Ä¤Þ¤ê¡¢cout ¤µ¤ó¤Ë "Èï²Ã¿ô? " ¤È¤¤¤¦Ê¸»úÎó¤ò½ÐÎÏ ¤·¤Æ¤¯¤À¤µ¤¤¤È¥á¥Ã¥»¡¼¥¸¤òÁ÷¤ë¤Î¤Ç¤¹¡£¤³¤Î¤è¤¦¤Ëʸ»úÎó¤Î¾ì¹ç¤Ï¡¢Ê¸»úÎó¤ò¡Ö"¡× ¤Ç°Ï¤ß¤Þ¤¹¡£Â³¤¤¤Æ cin » x; ¤Ë¤è¤Ã¤Æ¡¢cin ¤µ¤ó¤Ë¥æ¡¼¥¶¤ÎÆþÎϤ·¤¿¿ô ¤òÊÑ¿ô x ¤ØÂåÆþ¤¹¤ë¤è¤¦¥á¥Ã¥»¡¼¥¸¤òÁ÷¤ê¤Þ¤¹¡£¤³¤Î¤è¤¦¤ËÊÑ¿ô¤ØÆþÎϤ¹¤ë¤Ë ¤Ï » ¤Îľ¸å¤ËÊÑ¿ô¤ò½ñ¤­¤Þ¤¹¡£¤½¤·¤Æ¡¢17 ¹Ô¤Î calc.Set(x); ¤Ë¤è¤Ã ¤Æ x ¤ÎÆâÍƤò¥ì¥¸¥¹¥¿¤ËÀßÄꤷ¤Þ¤¹¤¬¡¢¤½¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¼¡¤Î¹à¤ò¸«¤Æ¤¯¤À ¤µ¤¤¡£Âè 18 ¹Ô¤Î²Ã¿ô¤ò y ¤ØÀßÄꤹ¤ëÊýË¡¤âƱÍͤǤ¹¡£

ÆþÎϤòÂ¥¤¹½ÐÎϤò¥×¥í¥ó¥×¥È¤È¤¤¤¤¤Þ¤¹¡£Ëܽñ¤Ç¤Ï¡¢¥×¥í¥ó¥×¥È¤Ë¤Ïɬ¤ººÇ¸å ¤Ë ? ¤ò¤Ä¤±¤ë¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢¼Â¹ÔÎã¤ò¸«¤ë¾ì¹ç ? ¤Îľ¸å¤ÏÆþÎϤǤ¢¤ë ¤ÈÍý²ò¤·¤Æ¤¯¤À¤µ¤¤¡£

¤Ê¤ªÊÑ¿ô¤ÎÆâÍƤò½ÐÎϤ¹¤ë¤Ë¤Ï cout « x; ¤Î¤è¤¦¤Ë « ¤Îľ¸å¤Ë ÊÑ¿ô¤òľÀܽñ¤­¤Þ¤¹¡£



¥á¥Ã¥»¡¼¥¸¤ÎÁ÷¿®

Âè 17¡¢19¡¢20 ¹Ô¤Ç¤Ï¥ª¥Ö¥¸¥§¥¯¥È calc ¤Ë¥á¥Ã¥»¡¼¥¸¤òÁ÷¤Ã¤Æ¤¤¤Þ¤¹¡£ Âè 14 ¹Ô¤ÇÀ¸À®¤·¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Ï¡¢¤½¤ÎÆâÉô¤Ë ¤½¤Î¥ª¥Ö¥¸¥§¥¯¥È¸ÇÍ­¤Î¥ì¥¸¥¹¥¿¤ò¤â¤Ã ¤Æ¤¤¤Þ¤¹¤·¡¢¤½¤Î¥ì¥¸¥¹¥¿¤ÎÁàºî¤ò¹Ô¤¦¥á¥ó¥Ð´Ø¿ô¤âÍøÍѲÄǽ¤Ç¤¹¡£¤Ç¤¹¤«¤é¡¢ ¼ê½ç½ñ¤­¤Ë¤¢¤ë¡Ö¥ì¥¸¥¹¥¿¤Ë¿ô¤òÀßÄꤹ¤ë¡×°Ê¹ß¤Î½èÍý¤¬²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£¤³¤ì ¤é¤ò¹Ô¤¦¤Ë¤Ï¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥á¥Ã¥»¡¼¥¸¤òÁ÷¤Ã¤Æ³Æ¥á¥ó¥Ð´Ø¿ô¤òµ¡Ç½¤µ¤»¤ì¤Ð¤è ¤¤¤Î¤Ç¤¹¡£

¥á¥Ã¥»¡¼¥¸ ¤ÎÁ÷¿®¤Ï°ìÈ̤ˤϼ¡¤Î¤è¤¦¤Ë¡¢ÂоݤȤ¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Î̾¤Ë¡Ö.¡× ¤ò¤Ä¤±¡¢¤µ¤é¤Ë¼Â¹Ô¤·¤Æ¤â¤é¤¤¤¿¤¤¥á¥ó¥Ð´Ø¿ô̾¤ò¤Ä¤±¤¿·Á¤Ç¹Ô¤ï¤ì¤Þ¤¹¡£

\begin{figure*}\begin{small}
\begin{screen}
\begin{verbatim}¥ª¥Ö¥¸¥§¥¯¥È̾ .¥...
...¿ô̾(¼Â°ú¿ô);\end{verbatim}
\end{screen}\end{small}\vspace{-1.5em}
\end{figure*}

¥ª¥Ö¥¸¥§¥¯¥È¤ËÂФ·¤Æ¥á¥ó¥Ð´Ø¿ô¤Î¸Æ½Ð¤·¤¬¤µ¤ì¤ë¤È¡¢¥×¥í¥°¥é¥à¤Î¼Â¹Ô½ç¤¬¡¢ ¸Æ¤Ó½Ð¤µ¤ì¤¿¥á¥ó¥Ð´Ø¿ôÆâ¤ÎºÇ½é¤Îʸ¤Ë°Ü¤ê¼Â¹Ô¤µ¤ì¤Þ¤¹¡£

main ´Ø¿ô¤Î 17 ¹Ô¤Ç¤Ï¡¢calc.Set(x) ¤Î·Á¤Ç´Ø¿ô¤ò¸Æ¤Ó½Ð¤·¤Æ¤¤¤Þ¤¹¡£¤³¤Î¤è ¤¦¤Ë¡¢´Ø¿ô¤¬°ú¿ô¤ò¤È¤ë¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢¤½¤Î¶ñÂÎŪ¤ÊÃͤò»ØÄꤷ ¤Æ´Ø¿ô¤ò¸Æ¤Ó½Ð¤·¤Þ¤¹¡£¤³¤Î¶ñÂÎŪ¤ÊÃͤΤ³¤È¤ò¼Â°ú¿ô¤È¤è¤Ó¤Þ¤¹¡£x ¤ÏÊÑ¿ô¤Ç ¤¹¤¬¡¢¤³¤Î¹Ô¤Þ¤Ç¤ËÃͤ¬·è¤Þ¤Ã¤Æ¤¤¤ë¤Î¤Ç¼Â°ú¿ô¤È¤·¤Æ»È¤¨¤Þ¤¹¡£¤³¤ÎÃͤϴؿô ÄêµÁ¦¤Î²¾°ú¿ô¤ËÅϤµ¤ì¡¢´Ø¿ôÆâ¤ÇÍøÍѤµ¤ì¤Þ¤¹¡£¶ñÂÎŪ¤Ë¤Ï¡¢¼Â°ú¿ô¤ÎÃͤ¬²¾ °ú¿ô¤Ë¥³¥Ô¡¼¤µ¤ì¡¢À©¸æ¤¬´Ø¿ô¦¡¢¤³¤Î¾ì¹ç¤Ë¤Ï¥¯¥é¥¹ CCalc ¤Î Set ¤Ë°ÜÆ°¤· ¤Þ¤¹¡£´Ø¿ô¤¬½êÄê¤Î»Å»ö¡¢¤Ä¤Þ¤ê¥ì¥¸¥¹¥¿¤Ë x ¤òÂåÆþ¤¹¤ëºî¶È¤ò¤·½ª¤ï¤ë¤È¡¢ À©¸æ¤¬´Ø¿ô¤Î¸Æ½Ð¤·°ÌÃÖ¡¢¤Ä¤Þ¤ê main ´Ø¿ô¤Î 17 ¹Ô¤ËÌá¤Ã¤Æ¤­¤Þ¤¹¡£¤³¤Î¤È ¤­´Ø¿ô¤ËÌáÃͤ¬¤¢¤ë¾ì¹ç¤Ï¡¢¤³¤ÎÃͤ¬¸Æ½Ð¤·°ÌÃ֤˥³¥Ô¡¼¤µ¤ì¤Þ¤¹¤¬¡¢¤³¤Î ¾ì¹ç¤Ë¤Ï void ¤ÈÌáÃͤ¬¤Ê¤¤¤Î¤Ç²¿¤âµ¯¤­¤Þ¤»¤ó¡£

Âè 18 ¹Ô¤Ç y ¤¬·èÄꤵ¤ì¤ë¤È¡¢¼¡¤ËÂè 19 ¹Ô calc.Add(y); ¤Ë¤è¤ê¡¢calc ¤Ë¥á ¥ó¥Ð´Ø¿ô Add(y) ¤Î¼Â¹Ô¤ò°ÍÍꤷ¤Þ¤¹¡£¤Þ¤º¡¢y ¤ÎÃͤ¬ Add ´Ø¿ô¦¤Î°ú¿ô x ¤Ë ¥³¥Ô¡¼¤µ¤ì¡¢¤«¤ÄÀ©¸æ¤¬ Add ´Ø¿ô¤ËÅϤµ¤ì¤Þ¤¹¡£¤½¤·¤Æ´Ø¿ôÆâ¤Î°ìʸ r += x; ¤Ë¤è¤Ã¤Æ¡¢¥ì¥¸¥¹¥¿¤Ë x ¤ò²Ã¤¨¤Þ¤¹¡£

Âè 20 ¹Ô¤ÎŤ¤Ê¸¤Ï¡¢r ¤Ëµ­²±¤µ¤ì¤Æ¤¤¤ëÃͤò cout ¤¹¤Ê¤ï¤Á¥Ç¥£¥¹¥×¥ì¥¤¤Ë ½ÐÎϤ¹¤ë¤â¤Î¤Ç¤¹¡£¤Þ¤º¡¢Ê¸Ãæ¤Î calc.Show() ¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤·¤ç¤¦¡£calc ¤Ë¥á¥Ã¥»¡¼¥¸ Show() ¤òÁ÷¤ë¤È¡¢´Ø¿ô Show ¤Ï°ú¿ô¤ò°ì¤Ä¤â¤â¤¿¤Ê¤¤¤Î¤Ç¡¢À©¸æ ¤Ïľ¤Á¤Ë´Ø¿ô Show ¤ËÅϤµ¤ì¤Þ¤¹¡£Show ´Ø¿ô¤Ç¤Ï¡¢return r; ¤Ë¤è¤ê¥ì¥¸¥¹ ¥¿¤ÎÆâÍƤòÊÖ¤¹¤³¤È¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢calc.Show() ¤Ï¥ì¥¸¥¹¥¿¤ÎÆâÍƤËÃÖ¤­´¹ ¤ï¤ê¤Þ¤¹¡£

¤³¤Î¤³¤È¤òÁ°Äó¤Ë¤·¤Æ½ÐÎÏʸ¤òÆɤó¤Ç¤ß¤Þ¤·¤ç¤¦¡£Âè 20 ¹Ô¤ò¸«¤Æ¤â¤é¤¦¤È¡¢É¸ ½à½ÐÎÏ¥ª¥Ö¥¸¥§¥¯¥È cout ¤Ë¡¢« ¤Ë¤è¤ê¼¡¡¹¤ÈÊÑ¿ô x¡¢Ê¸»úÎó " + "¡¢ ÊÑ¿ô y¡¢Ê¸»úÎó " = "¡¢calc.Show() ¤Î·ë²Ì¡¢Ê¸»ú '\n' ¤¬Á÷¤é¤ì¤Æ¤¤ ¤­¤Þ¤¹¡£¥Ç¥£¥¹¥×¥ì¥¤¤Ë¤Ï¤³¤ì¤é¤¬½ç¼¡É½¼¨¤µ¤ì¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£Ê¸»ú¤Ï°ìÈÌ ¤Ë 'A' ¤Ê¤É¤Î¤è¤¦¤Ë¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤Ç°Ï¤ß¤Þ¤¹¤¬¡¢'\n' ¤ÏÆüì¤Ê ʸ»ú¤Ç¡¢¥Ç¥£¥¹¥×¥ì¥¤¤Ë¤Ï²¿¤Îʸ»ú¤âɽ¼¨¤·¤Þ¤»¤ó¤¬¡¢Âå¤ï¤ê¤Ë°õ»ú°ÌÃÖ¤ò²þ¹Ô ¤µ¤»¤ëƯ¤­¤ò¤â¤Á¤Þ¤¹¡£

ºÇ¸å¤Ë¡¢°Ê¾å¤Îʸ¤òÊñ´Þ¤¹¤ë main ´Ø¿ô¤Î¹½Â¤¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤·¤ç¤¦¡£main ´Ø¿ô¤ÎÄêµÁ¤â¥á¥ó¥Ð´Ø¿ô¤ÈƱÍͤǡ¢°Ê²¼¤Î¤è¤¦¤Ê¹½Â¤¤ò¤·¤Æ¤¤¤Þ¤¹¡£

\begin{figure*}\begin{small}
\begin{screen}
\begin{verbatim}ÌáÃͤη¿ main(²¾°...
...˴ؤ¹¤ëµ­½Ò }\end{verbatim}
\end{screen}\end{small}\vspace{-1.5em}
\end{figure*}

ÆÃÊ̤ʴؿô¤È¤Ï¤¤¤¨ main ¤â´Ø¿ô¤Ç¤¹¤«¤éÌáÃͤä°ú¿ô¤ò¤â¤Ä¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£°ì È̤δؿô¤È°Û¤Ê¤ê main ´Ø¿ô¤Ï¾¤Î´Ø¿ô¤«¤é¸Æ¤Ó½Ð¤µ¤ì¤ë¤³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¡£¤Ç¤â¡¢ main ´Ø¿ô¤âÌáÃͤä°ú¿ô¤ò¤â¤Ä¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

¤Ç¤Ï¡¢ÌáÃͤϤɤ³¤ËÊÖ¤µ¤ì¤ë¤Î¤Ç¤·¤ç¤¦¤«¡£°ú¿ô¤Ï¤É¤³¤«¤é¶ñÂÎŪ¤ÊÃͤòÍ¿¤¨ ¤é¤ì¤ë¤Î¤Ç¤·¤ç¤¦¤«¡£¤½¤ì¤Ï¡¢¤³¤Î¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤·¤¿¥×¥í¥°¥é¥à¤¹¤Ê¤ï¤Á¡¢ ¥ª¥Ú¥ì¡¼¥Æ¥£¥ó¥°¥·¥¹¥Æ¥à¤È¥æ¡¼¥¶¤È¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤ò¤È¤ë¥·¥§¥ë¤È¤«¥³¥Þ ¥ó¥É¥é¥¤¥ó¥¤¥ó¥¿¡¼¥×¥ê¥¿¤È¤«¤è¤Ð¤ì¤ë¥×¥í¥°¥é¥à¤Ç»ØÄꤷ¤¿¥Ç¡¼¥¿¤Ë¤è¤Ã¤ÆÃÍ ¤¬Í¿¤¨¤é¤ì¤Þ¤¹¡£¤Ê¤ª¡¢¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô¤Ë¤Ä¤¤¤Æ¤Î¾ÜºÙ¤Ï[*]¾Ï ¤ÇÀâÌÀ¤·¤Þ¤¹¡£

main ´Ø¿ô¤ÏÀ°¿ô 0 ¤òÊÖ¤·¤Æ¤¤¤Þ¤¹¤¬¡¢¤½¤ì¤â¾å°Ì¤Î¥×¥í¥°¥é¥à¤ËÊÖ¤µ¤ì¤Þ¤¹¡£ °ìÈÌ¤Ë¥×¥í¥°¥é¥à¤¬Ìµ»ö¤Ë½ªÎ»¤·¤¿¤È¤­¤Ë¤Ï 0 ¤òÊÖ¤¹Ìó«¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤· ¤¿¤¬¤Ã¤Æ main ´Ø¿ô¤ÎÌáÃͤη¿¤Ï int ¤È¤·¤Þ¤¹¡£¤Þ¤¿¡¢¤³¤Î¥×¥í¥°¥é¥à¤Ç¤Ï¥³ ¥Þ¥ó¥É¥é¥¤¥ó¤«¤é main ¤Ë¥Ç¡¼¥¿¤òÍ¿¤¨¤ëɬÍפâ¤Ê¤¤¤Î¤Ç¡¢°ú¿ô¤Ï¼è¤é¤Ê¤¤¤³¤È ¤È¤·( )¤ÎÃæ¤Ï¶õ¤Ë¤·¤Þ¤·¤¿¡£



¥×¥ê¥×¥í¥»¥Ã¥µ

Âè 12 ¹Ô¤Ë¸½¤ì¤¿ #include ... ¤Î¤è¤¦¤Ë¡¢# ¤Ç»Ï¤Þ¤ëµ­½Ò¤Ï¥×¥ê ¥×¥í¥»¥Ã¥µ»ØÎá¤È¤è¤Ð¤ì¡¢¥×¥í¥° ¥é¥à¤ò·×»»µ¡¤Î¤ï¤«¤ëµ¡³£¸ì¤ËËÝÌõ¤¹¤ëºÝ¤ËɬÍפÊÍÍ¡¹¤ÊÁ°½èÍý¤ò»ØÎᤷ¤Þ¤¹¡£ µ¡³£¸ì¤Ë¤É¤Î¤è¤¦¤ËËÝÌõ¤·¤Æ¤¤¤¯¤«¤Ë¤Ä¤¤¤Æ¤Ï¼¡Àá¤Ç½Ò¤Ù¤Þ¤¹¤¬¡¢#include ... ¤Ï¡¢C ¤ä C++ ¤Ë¤¢¤é¤«¤¸¤áÈ÷¤¨¤é¤ì¤Æ¤¤¤ë¤¤¤¯¤Ä¤«¤Î¥é¥¤¥Ö¥é¥ê´Ø¿ô¤È ¤è¤Ð¤ì¤ë´Ø¿ô¤ò»È¤¦ºÝ¤ËɬÍפÀ¤È¤À¤±³Ð¤¨¤Æ¤¯¤À¤µ¤¤¡£Î㤨¤Ð¡¢¤³¤³¤Ç»È¤Ã¤Æ ¤¤¤ë cout « ... ¤ä cin » ... ¤È¤¤¤¦µ¡Ç½¤Ï¡¢¤¢¤È¤Î¾Ï¤ÇÀâÌÀ¤¹¤ë¤è¤¦¤Ë¡¢ÁÈ ¹þ¤ß´Ø¿ô¤Î°ì¼ï¤Ç¤¹¡£¤·¤«¤·¡¢ÌۤäƤ¤¤Æ¤â»È¤¨¤Þ¤»¤ó¡£´Ø¿ô¤Î»È¤¤Êý¤äÄêµÁ ¤Ê¤É¤Î½ñ¤«¤ì¤¿¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë ¤È¤è¤Ð¤ì¤ë¤â¤Î¤ò²æ¡¹¤Î¥×¥í¥°¥é¥à¤ØÁȤ߹þ¤àɬÍפ¬¤¢¤ê¤Þ¤¹¡£

¤½¤ì¤Ë¤Ï¡¢¾åµ­¥×¥í¥°¥é¥à¤Ë¤¢¤ë¤è¤¦¤Ë #include <iostream.h> ¤È½ñ¤¯¤³¤È ¤ÇãÀ®¤µ¤ì¤Þ¤¹¡£#include ¤Ë¤è¤Ã¤Æ¡¢¸å¤í¤Î < > Æâ¤Ç»ØÄꤷ¤¿¥Õ¥¡¥¤¥ë¤¬¡¢¤½ ¤Î°ÌÃÖ¤ËÁÞÆþ¤µ¤ì¤Þ¤¹¡£iostream.h ¥Õ¥¡¥¤¥ë¤Ï C++ ¤¬É¸½à¤ÇÊÝ»ý¤·¤Æ ¤¤¤ë¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤Î°ì¤Ä¤Ç¡¢Æþ½ÐÎϤʤɤ˴ط¸¤·¤¿´ðËÜŪ¤Ê¾ðÊ󤬵­½Ò¤µ¤ì¤Æ ¤¤¤Þ¤¹¡£°Ê¹ß¤Î¥×¥í¥°¥é¥ß¥ó¥°¤Ë¤ª¤¤¤Æ¤Ï¡¢¤Û¤È¤ó¤É¤¹¤Ù¤Æ¤Î¥×¥í¥°¥é¥à¤ÇÆþ ½ÐÎϤò¤·¤Þ¤¹¤Î¤Ç¡¢É¬¤º¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤Ë #include <iostream.h> ¤òÁÞÆþ¤· ¤Þ¤¹¡£


ÌäÂê2 ¡¡ ¤¢¤ëÂç³Ø¤Î³ØÀÒÈÖ¹æ¤Ï¡¢¾å°Ì 2 ·å¤¬Æþ³Øǯ Å٤β¼ 2 ·å¡¢²¼ 2 ·å¤¬³ØÀ¸¤Î°ìÏ¢ÈÖ¹æ¤òɽ¤·¤Æ¤¤¤Þ¤¹¡£ÌäÂê1¤ÇÄɲä·¤¿ CCalc ¤Î¥á¥½¥Ã¥É¤òÍѤ¤¤Æ¡¢³ØÀÒÈÖ¹æ¤òɽ¤¹ 4 ·å¤ÎÀ°¿ô¤òÆɤ߹þ¤ß¡¢Æþ³ØǯÅ٤ȰìÏ¢ÈÖ¹æ¤ò²èÌ̤˽ÐÎϤ¹¤ë¥×¥í¥°¥é¥à¤ò½ñ¤¤¤Æ ¤¯¤À¤µ¤¤¡£


next up previous contents index
Next: ¥×¥í¥°¥é¥à³«È¯¤Î¼ê½ç Up: ¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¥×¥í¥°¥é¥ß¥ó¥° Previous: ¥¯¥é¥¹¤ÎÀß·×   Contents   Index
Yoichi OKABE 2006-05-20