C_ÔÚswitch
Ô´Â룺
# include <stdlib.h>
# include <stdio.h>
int main()
{
int month;
int day;
printf("please input the month number: ");
scanf("%d", &month);
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: day=31; // ÓÐ31ÌìµÄÔ·ÝÇé¿ö
break;
case 4:
case 6:
case 9:
case 11: day=30; // ÓÐ30ÌìµÄÔ·ݵÄÇé¿ö
break;
case 2: day=28; // ·ÇÈòÄêµÄ2ÔÂÓÐ28Ìì
break;
default: exit(0);
}
printf("1999.%d has %d days.\n", month, day);
return 0;
}
ÆäÖУ¬ÈôÄÜ°´ÊäÈëÄê·Ý·ÖΪÈòÄêºÍ·ÇÈòÄêÊä³öÿÔÂÌìÊý£¬¿ÉÄܸüºÃ¡££¨´ý½â¾ö£©
Ïà¹ØÎĵµ£º
C++¶Ôʱ¼äµÄ²Ù×÷Ò²ÓÐÐí¶àÖµµÃ´ó¼Ò×¢ÒâµÄµØ·½¡£×î½ü£¬ÔÚ¼¼ÊõȺÖÐÓкܶàÍøÓÑÒ²¶à´ÎÎʵ½¹ýC++ÓïÑÔÖжÔʱ¼äµÄ²Ù×÷¡¢»ñÈ¡ºÍÏÔʾµÈµÈµÄÎÊÌâ¡£ÏÂÃ棬ÔÚÕâƪÎÄÕÂÖУ¬±ÊÕß½«Ö÷Òª½éÉÜÔÚC/C++ÖÐʱ¼äºÍÈÕÆÚµÄʹÓ÷½·¨.
ͨ¹ýѧϰÐí¶àC/C++¿â£¬Äã¿ÉÒÔÓкܶà²Ù×÷¡¢Ê¹ÓÃʱ¼äµÄ·½·¨¡£µ«Ô ......
ͻ񻣼
±¾ÎÄ´Ó½éÉÜ»ù´¡¸ÅÄîÈëÊÖ£¬Ì½ÌÖÁËÔÚC/C++ÖжÔÈÕÆÚºÍʱ¼ä²Ù×÷ËùÓõ½µÄÊý¾Ý½á¹¹ºÍº¯Êý£¬²¢¶Ô¼Æʱ¡¢Ê±¼äµÄ»ñÈ¡¡¢Ê±¼äµÄ¼ÆËãºÍÏÔʾ¸ñʽµÈ·½Ãæ½øÐÐÁ˲ûÊö¡£±¾ÎÄ»¹Í¨¹ý´óÁ¿µÄʵÀýÏòÄãչʾÁËtime.hÍ·ÎļþÖÐÉùÃ÷µÄ¸÷ÖÖº¯ÊýºÍÊý¾Ý½á¹¹µÄÏêϸʹÓ÷½·¨¡£
¹Ø¼ü×Ö£ºUTC£¨ÊÀ½ç±ê׼ʱ¼ä£©£¬Calendar Time£¨ÈÕÀúʱ¼ä£©£¬epoch ......
Ô´Âë:
# include <stdio.h>
int main()
{
/* ¶¨ÒåÒ»¸öÕûÐÎÖ¸Õëp */
int *p;
int begin, end;
begin = 10;
/* ¸øÖ¸Õëp¸³³õÖµ */
p = &begin;
& ......
Ô´Âë:
# include <stdio.h>
int main()
{
int i, j, k;
/* ±äÁ¿i´Ó0µ½4£¬±íʾËù»ÁâÐÎͼµÄµÚÒ»ÖÁµÚÎåÐÐ */
for(i = 0; i <= 4; i++)
{
/* ......