输入某一年 以及某一年的天数 就 是几月的第几天
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
int Monthday(int year,int yearDay,int *pMonth,int *pDay);
int dayTab[2][13] = {{0,31,28,31,30,31,30,31,31,30,31,30,31},
{0,31,29,31,30,31,30,31,31,30,31,30,31}};
int main()
{
int year,month,day,yearDay;
printf_s("Please enter year,yearDay:");
scanf_s("%d,%d",&year,&yearDay);
MonthDay(year,yearDay,&month,&day);
printf_s("month = %d,day = %d
",month,day);
system("pause");
return 0;
}
void MonthDay(int year,int yearDay,int *pMonth,int *pDay)
{
int i,leap;
leap = ((year%4 == 0)&&(year % 100 !=0) || (year % 400 == 0));
for(i = 1;yearDay>dayTab[leap][i];i++)
{
yearDay = yearDay -dayTab[leap][i];
}
*pMonth = i;
*pDay = yearDay;
}
pmonth pday 就是返回两个参数