//定义一个结构体变量(包括年、月、日),写一个days函数实现计算是一年中的第几天?由函数将年、月、日传递给days函数,计算后将日子数传回主函数输出
#include<stdio.h>
struct dayss        //这是定义结构体变量
{
 int y;
 int m;
 int d;
}di;
int days(struct dayss di)                  //这是计算一年当中第几天的函数
{
 int day[2][12]={{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; 
 int leap,i;
 if((di.y%4==0 && di.y%100!=0) || (di.y%400==0))
  leap=1;
 else 
  leap=0;
    for(i=0;i<di.m-1;i++) 
  di.d+=day[leap][i];
 return di.d;                        //最后返回一年当中第几天的值
}
void main()
{
 struct dayss di;
 int days;
 printf("请输入年份:");
 scanf("%d",&di.y);
 printf("请输入月份:");
 scanf("%d",&di.m);
 printf("请输入天数:");
 scanf("%d",&di.d);
 days=days(di);                  //调用函数
 
 printf("%d年%d月%d日是一年当中第%d",di.y,di.m,di.d,days);
}
C:\Documents and Settings\英雄\桌面\aaa\Cpp1.cpp(30) : error C2064: term does not evaluate to a function
Error executing cl.exe.
Cpp1.exe - 1 error(s), 0 warning(s)

 
											





 
	    

