oj--计算该日是本月中第几天

代码:

/*
*Copyright (c) 2016, 烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:计算该日在本年中是第几天;
*作    者:岳成艳;
*完成日期:2016年4月15号;
*版 本 号:vc++6.0;
*问题描述:定义一个结构体变量(包括年、月、日)。编写一个函数days,由主函数将年、月、日传递给函数days,计算出该日在本年中是第几天并将结果传回主函数输出。
*输入描述:年月日;
*程序输出:当年第几天;
*/
#include 
using namespace std;
struct y_m_d
{
    int year;
   int month;
    int day;
};
int days(struct y_m_d date)
{
     int M[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  int i,sum=0,day_sum=0;

  if((date.year%4==0&&date.year%100!=0)||date.year%400==0)
  {
     M[2]=29;
  }
  for(i=0,sum=0;i>date.year>>date.month>>date.day;
    day_sum=days(date);
    cout<

运行测试:

oj--计算该日是本月中第几天_第1张图片

你可能感兴趣的:(c++,vc++6.0,编程,c++)