| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 481 人关注过本帖
标题:这个程序出了什么问题?
只看楼主 加入收藏
wasijing
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-8-2
收藏
 问题点数:0 回复次数:8 
这个程序出了什么问题?
#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 
2007-08-02 16:35
bupthehe
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2007-8-2
收藏
得分:0 
#include <stdbool.h>

我这怎么找不到这个头文件
2007-08-02 16:42
wasijing
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-8-2
收藏
得分:0 
我也是找不到这个头文件
但这个应该没错啊 书上都是这样的
难道是win-tc不好用?
2007-08-03 11:39
bupthehe
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2007-8-2
收藏
得分:0 
回复:(wasijing)我也是找不到这个头文件但这个应该...
turb c中本身不包含这个头函数
2007-08-03 11:49
anlogo
Rank: 2
等 级:论坛游民
威 望:1
帖 子:293
专家分:20
注 册:2007-7-20
收藏
得分:0 
#include <stdbool.h>
2007-08-03 12:16
wasijing
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-8-2
收藏
得分:0 
那要怎样才能通过编译呢?
2007-08-03 12:21
medicihophy
Rank: 1
等 级:新手上路
威 望:1
帖 子:102
专家分:0
注 册:2007-7-28
收藏
得分:0 
以下是引用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上编译失败呢?请大家帮帮忙看看


2007-08-03 19:45
wasijing
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-8-2
收藏
得分:0 
。。。。。。万分感激楼上仁兄
2007-08-05 12:18
小野猫
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2007-7-13
收藏
得分:0 
论坛里没高手啊?

2007-08-05 17:53
快速回复:这个程序出了什么问题?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015387 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved