大致的帮你把语法错误改好了~
主要两个问题:
第一,您的结构定义在main里边,而两个函数又定义在main上边,所以编译两个函数的时候编译器并不知道结构的存在,已做修改;
第二,实参和形参不一致,已修改。
嘻嘻,朋友有空也多帮大家回答问题互动哦~努力共建一个和谐、互助的学习型社区!#include <stdio.h>
struct date //时间变量的声明
{
int year;
int month;
int day;
};
int numberofday1 (struct date now);//如果month <= 2 计算n1的天数的公式
int numberofday2 (struct date now);//如果month >=2 && month <= 12 计算n2的天数的公式
int main (void)
{
struct date now;
int date1, date2, numberofdate;
printf("inter your date1:\n");//输入你想要的日期
scanf ("%2i %i %i", &now.year, &now.month, &now.day);
if (now.month <= 2)//判断月份
date1 = numberofday1 (now);
else if (now.month >2 && now.month <= 12)
date1 = numberofday2 (now);
else
printf ("the errer date!");
printf("inter your date2:\n");//输入你想要的日期
scanf ("%2i %i %i", &now.year, &now.month, &now.day);
if (now.month <= 2)//判断月份
date2 = numberofday1 (now);
else if (now.month >2 && now.month <= 12)
date2 = numberofday2 (now);
else
printf ("the errer date!");
numberofdate = date1 - date2;//计算两个日期的天数
printf("the number of day is %2i", numberofdate);
return 0;
}
int numberofday1 (struct date now)//如果month <= 2 计算n1的天数的公式
{
int n1;
n1 = ((1461 * (now.year - 1)) / 4 + (153 * (now.month + 13))) + now.day;
return n1;
}
int numberofday2 (struct date now)//如果month >=2 && month <= 12 计算n2的天数的公式
{
int n2;
n2 = ((1461 * now.year) / 4 + (153 * (now.month + 1))) + now.day;
return n2;
}
|