diff --git a/2207/C语言同步练习/选择结构/4.c b/2207/C语言同步练习/选择结构/4.c new file mode 100644 index 0000000..7443d2e --- /dev/null +++ b/2207/C语言同步练习/选择结构/4.c @@ -0,0 +1,31 @@ +#include + +int main(){ + + int year, month, day, days=0; + + scanf("%d-%d-%d", &year, &month, &day); + days+=day; + //1 3 5 7 8 10 12 + //ǰһ¿ʼ + switch(month-1){ + case 11:days+=30; + case 10:days+=31; + case 9:days+=30; + case 8:days+=31; + case 7:days+=31; + case 6:days+=30; + case 5:days+=31; + case 4:days+=30; + case 3:days+=31; + case 2:days+=28; + case 1:days+=31; + } + if(month>3 && (year%4==0&&year%100!=0 || year%400==0)){ + days++; + } + printf("%d\n", days); + + + return 0; +} diff --git a/2207/C语言同步练习/选择结构/4.exe b/2207/C语言同步练习/选择结构/4.exe new file mode 100644 index 0000000..7c068bf Binary files /dev/null and b/2207/C语言同步练习/选择结构/4.exe differ