public static int[] yue = new int[13];
static void Main(string[] args)
{
int p1, p11, p12,p=0 ;
//计算出1999年5月10日到2006年3月8日期间一共有多少天?
//【用户输入两个日期】-----【程序】-----【输出两个日期间的天数】。// 1 3 5 7 8 10 12 2 4 6
Console.WriteLine(闰年(2000));
月();
Console.WriteLine(天(2000,2));
Console.WriteLine("请输入起始日期");
int [] time1=new int [3];
for (int i=0;i <time1 .Length ;i ++)
{
time1 = Convert.ToInt32(Console.ReadLine());
}
int[] time2 = new int[3];
Console.WriteLine("请输入截止日期");
for (int i=0;i <time1 .Length ;i ++)
{
time2 [i ]= Convert.ToInt32(Console.ReadLine());
}//1999 5 10--2006 3 8 1999 5-2006 3 hai 5yue duo 10tian 3yue shao 8tian -2 tian ?2000 2001 2002 2003 2004 2005 6nian? 5-12 7yue 0-3 3yue +10yue
//6nian 10yue -2tian //2000runnian 366 2001 ping 365 2002 ping 365 2003 ping 365 2004 run366 2005 ping 365 2006 ping 365 6nian 4ge 365 2ge 366 365 4 1460 366 2 732 =2192
//1999ping 365 1yue 3 yue 62tian 2yue 28tian 5yue31 30tian 58 62 151tian 365-151=214 2006 ping 1yue 31 2yue 28tian 31 +28=90
//2192+245+59-2=2494
if (time2[1] - time1[1] >= 0 && time2[2] - time1[2] >= 0)
{
p1=(time2 [0]-time1 [0])*12;
p11 = 12 - time1[1]+1;
p12 = time2[1]-1;
p = p1 + p11 + p12;
}
else
{
p1=(time2 [0]-time1 [0]-1)*12;
p11 = 12 - time1[1]+1;
p12 = time2[1]-1;
p = p1 + p11 + p12;
}
Console.WriteLine("一共有多少个{0}",p );
int [] s=new int [p];
Console.ReadKey();
}
static string 闰年(int s)
{
string result;
if (s % 400 == 0 || (s / 100 != 0 && s / 4 == 0))
{
result = "闰年";
}
else
{
result = "不是闰年";
}
return result;
}
static void 月()
{
int[] dayue = { 1, 3, 5, 7, 8, 10, 12 };
int[] xiaoyue = { 4, 6, 9, 11 };
int[] eryue = { 2 };
for (int i = 0; i < dayue.Length; i++)
{
yue[dayue] = 1;
}
for (int i = 0; i < xiaoyue.Length; i++)
{
yue[xiaoyue] = 2;
}
for (int i = 0; i < eryue.Length; i++)
{
yue[eryue] = 3;
}
}
static string 天(int v ,int s)
{
string result = 闰年(v);
if (result == "闰年")
{
switch (yue)
{
case 1:
result = "31天";
break;
case 2:
result = "30天";
break;
case 3:
result = "29天";
break;
}
return result;
}
else
{
switch (yue)
{
case 1:
result = "31天";
break;
case 2:
result = "30天";
break;
case 3:
result = "28天";
break;
}
return result;
}
就是想得到的多少个月 每个值都弄到那个得到的数组里面 然后下面不是有对比月多少天的吗 然后对比 然后循环取值下 我是这样想的 汗 不知道可以不的?
|