当前位置: 代码迷 >> C语言 >> 求助(急)
  详细解决方案

求助(急)

热度:140   发布时间:2006-02-23 10:58:00.0
求助(急)
main()
{
struct date
{int year;
int month;
int day;};
int i,days=0;
int a[13]={0,0,31,28,31,30,31,30,31,31,30,31,30};
printf("Input year month day:\n");
scanf("%d,%d,%d",&date.year,&date.month,&date.day);
for(i=1;i<=date.month;i++)
days=days+a[i];
days=date.day+days;
if((date.year%4==0&&date.year%100!=0||date.year%400==0)&&date.month>2)
days=days+1;
printf("%d",days);
}
编译时,系统说没有定义date,为什么,结构体是怎么定义的请各位大侠指点
----------------解决方案--------------------------------------------------------
main()
{
struct date
{int year;
int month;
int day;}; /*这一句改成int day;}date; 就可以了 */
int i,days=0;
int a[13]={0,0,31,28,31,30,31,30,31,31,30,31,30};
printf("Input year month day:\n");
scanf("%d,%d,%d",&date.year,&date.month,&date.day);
for(i=1;i<=date.month;i++)
days=days+a[i];
days=date.day+days;
if((date.year%4==0&&date.year%100!=0||date.year%400==0)&&date.month>2)
days=days+1;
printf("%d",days);
}



----------------解决方案--------------------------------------------------------
我试一下
----------------解决方案--------------------------------------------------------
可以了,谢了,大侠
----------------解决方案--------------------------------------------------------
其实dos.h中已经有定义了这个结构体
----------------解决方案--------------------------------------------------------
  相关解决方案