IT强
2015-07-07 16:02
#include <stdio.h> int main() { /* 定义需要计算的日期 */ int year = 2008; int month = 8; int day = 8; int i =1; int num=0; if( ; i<month; i++) { switch(i) { case 1 : num= num +31; break; case 2: nun = num +29; break; case 3: num=num+31 ; break; case 4 : num = num +30; break; case 5: num = num+31; break; case 6 : num = num+30; break; case 7 : num = num +31 ; break; } num = num ; } else { printf("%dnum="num+day); } return 0; }
if( ; i<month; i++) //if--替换成for { switch(i) { case 1 : num= num +31; break; case 2: nun = num +29; break; case 3: num=num+31 ; break; case 4 : num = num +30; break; case 5: num = num+31; break; case 6 : num = num+30; break; case 7 : num = num +31 ; break; } num = num ; //这句啥意思?num+=day; } else { printf("%dnum="num+day); //不需要用else,直接printf("%dnum=",num); }
C语言入门
926210 学习 · 20797 问题
相似问题