请各位指教一下,如果用scanf语句 这个有什么问题么?
#include <stdio.h>
int main()
{
/* 定义需要计算的日期 */
int year;
int month;
int day;
printf("请输入年月日\n");
scanf_s("%d,%d,%d",&year,&month,&day);
int sum;
switch (month)
{
case 1:sum = 0; break;
case 2:sum = 31; break;
case 3:sum = 59; break;
case 4:sum = 89; break;
case 5:sum = 120; break;
case 6:sum = 150; break;
case 7:sum = 181; break;
case 8:sum = 212; break;
case 9:sum = 242; break;
case 10:sum = 273; break;
case 11:sum = 303; break;
case 12:sum = 334; break;
default:printf("一年中只有十二个月哦");
}
if (year % 400 ==0 || year % 4 ==0 && year%100 != 0)
{
if (month > 2)
{
sum = sum + day + 1;
}
else
{
sum = sum + day;
}
printf("%d年%d月中的第%d天\n",year,month ,sum);
}
return 0;
}