当前位置: 代码迷 >> C语言 >> 这个程序出了什么问题?
  详细解决方案

这个程序出了什么问题?

热度:198   发布时间:2007-08-02 16:35:40.0
这个程序出了什么问题?
#include <stdio.h>
#include <stdbool.h>
struct date
{
int month;
int day;
int year;
};

int main(void)
{
struct date today,tomorrow;
int numberofdays(struct date a);

printf("Enter today's date(mm dd yyyy):");
scanf("%i%i%i",&today.month,&today.day,&today.year);
if(today.day!=numberofdays(today))
{
tomorrow.day=today.day+1;
tomorrow.month=today.month;
tomorrow.year=today.year;
}
else if(today.month==12)
{
tomorrow.day=1;
tomorrow.month=1;
tomorrow.year=today.year+1;
}
else
{
tomorrow.day=1;
tomorrow.month=today.month+1;
tomorrow.year=today.year;
}
printf("Tomorrow's date is %i/%i/%.2i.\n",tomorrow.month,tomorrow.day,
tomorrow.year%100);

return 0;

}

int numberofdays(struct date a)
{
int days;
bool isleapyear(struct date a)
const int dayspermonth[12]={31,28,31,30,31,30,31,31,30,31,30,31};

if(isleapyear(a)==true&&a.month==2)
days=29;
else
days=dayspermonth[a.month-1];
return days;
}

bool isleapyear(struct date a)
{
bool leapyearflag;

if((a.year%4==0&&a.year%100!=0)||
a.year%400==0)
leapyearflag=true;
else
leapyearflag=false;

return leapyearflag;
}

请问这个程序哪里出了问题?为什么在win-tc上编译失败呢?请大家帮帮忙看看
搜索更多相关的解决方案: void  include  Enter  

----------------解决方案--------------------------------------------------------
#include <stdbool.h>

我这怎么找不到这个头文件
----------------解决方案--------------------------------------------------------
我也是找不到这个头文件
但这个应该没错啊 书上都是这样的
难道是win-tc不好用?

----------------解决方案--------------------------------------------------------
回复:(wasijing)我也是找不到这个头文件但这个应该...
turb c中本身不包含这个头函数
----------------解决方案--------------------------------------------------------
#include <stdbool.h>

----------------解决方案--------------------------------------------------------
那要怎样才能通过编译呢?
----------------解决方案--------------------------------------------------------
以下是引用wasijing在2007-8-2 16:35:40的发言:

#include <stdio.h>
#include <stdbool.h>
struct date
{
int month;
int day;
int year;
};

int main(void)
{
struct date today,tomorrow;
int numberofdays(struct date a);

printf("Enter today's date(mm dd yyyy):");
scanf("%i%i%i",&today.month,&today.day,&today.year);
if(today.day!=numberofdays(today))
{
tomorrow.day=today.day+1;
tomorrow.month=today.month;
tomorrow.year=today.year;
}
else if(today.month==12)
{
tomorrow.day=1;
tomorrow.month=1;
tomorrow.year=today.year+1;
}
else
{
tomorrow.day=1;
tomorrow.month=today.month+1;
tomorrow.year=today.year;
}
printf("Tomorrow's date is %i/%i/%.2i.\n",tomorrow.month,tomorrow.day,
tomorrow.year%100);

return 0;

}

int numberofdays(struct date a)
{
int days;
bool isleapyear(struct date a)斗大的个错误在这里诞生了!不用指明吧!
const int dayspermonth[12]={31,28,31,30,31,30,31,31,30,31,30,31};

if(isleapyear(a)==true&&a.month==2)
days=29;
else
days=dayspermonth[a.month-1];
return days;
}

bool isleapyear(struct date a)
{
bool leapyearflag;

if((a.year%4==0&&a.year%100!=0)||
a.year%400==0)
leapyearflag=true;
else
leapyearflag=false;

return leapyearflag;
}

请问这个程序哪里出了问题?为什么在win-tc上编译失败呢?请大家帮帮忙看看


----------------解决方案--------------------------------------------------------
。。。。。。万分感激楼上仁兄
----------------解决方案--------------------------------------------------------
论坛里没高手啊?
----------------解决方案--------------------------------------------------------

  相关解决方案