用中间变量做这个题

1、“请输入年份:”(1-9999)
“请输入月份:”(1-12)
“请输入日期:”(要判断大小月,判断闰年)
判断输入的时间日期是否正确

2、计算输入的时间是当前这一年的第几天

namespace _2017_2_23判断日期格式优化代码
{
class Program
{
static void Main(string[] args)
{
bool dateISOK = false;
bool isRN = false;
{
int year; int month = ; int day = ;int num=;
Console.WriteLine("请输入年份:(1-9999)");
year = Convert.ToInt32(Console.ReadLine());
if (year >= && year <= )
{
if (year >= && year <= && year % == && year % != || year % == )
{
isRN = true;
}
Console.WriteLine("请输入月份:");
month = Convert.ToInt32(Console.ReadLine());
if (month >= && month <= )
{
Console.WriteLine("请输入日期:");
day = Convert.ToInt32(Console.ReadLine());
if (month == || month == || month == || month == || month == || month == || month == && day >= && day<= )
{
Console.WriteLine("您输入的日期格式正确");
dateISOK = true; } else if ((month == || month == || month == || month == ) && day >= && day <= )
{
Console.WriteLine("您输入的日期格式正确");
dateISOK = true; }
else if (isRN==true && month == && day >= && day <= )
{
Console.WriteLine("您输入的日期格式正确");
dateISOK = true;
isRN = true; }
else if (isRN==false && month == && day >= && day <= )
{
Console.WriteLine("您输入的日期格式正确");
dateISOK = true; } else
{
Console.WriteLine("您输入的日期格式不对");
}
}
else
{
Console.WriteLine("您输入的月份格式错误");
}
}
else
{
Console.WriteLine("您输入的年份格式错了");
}
if(dateISOK==true&&month==)
{
num = day;
}
if(dateISOK==true&&month==)
{
num = + day;
}
if(dateISOK==true&&month==&&isRN==true)
{
num = + + day;
}
if(dateISOK==true&&month==&&isRN==false)
{
num = + + day;
}
if (dateISOK == true && month == && isRN == true)
{
num = + ++ day;
}
if (dateISOK == true && month == && isRN == false)
{
num = + + + day;
}
if (dateISOK == true && month == && isRN == true)
{
num = + + ++ day;
}
if (dateISOK == true && month == && isRN == false)
{
num = + + ++ day;
}
if (dateISOK == true && month == && isRN == true)
{
num = + + + + + day;
}
if (dateISOK == true && month == && isRN == false)
{
num = + + + + + day;
}
if (dateISOK == true && month == && isRN == true)
{
num = + + + + + + day;
}
if (dateISOK == true && month == && isRN == false)
{
num = + + + + + + day;
}
if (dateISOK == true && month == && isRN == true)
{
num = + + + + + ++ day;
}
if (dateISOK == true && month == && isRN == false)
{
num = + + + + + + + day;
}
if (dateISOK == true && month == && isRN == true)
{
num = + + + + + + + + day;
}
if (dateISOK == true && month ==&& isRN == false)
{
num = + + + + + + ++ day;
}
if (dateISOK == true && month == && isRN == true)
{
num = + + + + + + + + + day;
}
if (dateISOK == true && month == && isRN == false)
{
num = + + + + + + + + + day;
}
if (dateISOK == true && month == && isRN == true)
{
num = + + + + + + + + ++ day;
}
if (dateISOK == true && month == && isRN == false)
{
num = + + + + + + + + ++ day;
}
if (dateISOK == true && month == && isRN == true)
{
num = + + + + + + + + + ++ day;
}
if (dateISOK == true && month == && isRN == false)
{
num = + + + + + + + + + ++ day;
}
Console.WriteLine("你输入的日期是当年的第"+num+"天");
Console.ReadLine();
} }
}
}

2017-2-23 C#基础 中间变量的更多相关文章

  1. 2017/05/23 java 基础 随笔

    1.多态的好处: a.提高了代码的维护性(继承保证) b.提高了代码的扩展性(由多态保证) package com.huawei; public class Demo2 { public static ...

  2. 2017 Android 面试题 [ 基础与细节 ]

    2017 Android 面试题 [ 基础与细节 ] 感谢@chuyao抛出的这些问题,平时业务代码写多了,很多基础的东西变得含糊不清了,这次裸辞出来找工作确实没有之前顺利,顺便求上海Android开 ...

  3. 总结 Date 2017.09.23

    总结 Date 2017.09.23 <1>统计数字 某次科研调查时得到了n个自然数,每个数均不超过1500000000(1.5*10^9).已知不相同的数不超过10000个,现在需要统计 ...

  4. SNS团队第二次站立会议(2017.04.23)

    一.当天站立式会议照片 本次会议主要内容:汇报工作进度,根据完成情况调整进度 二.每个人的工作 成员 今天已完成的工作 明天计划完成的工作 罗于婕 梳理清楚数据的每个类型和数据项  具体落实把相关数据 ...

  5. SNS团队Beta阶段第二次站立会议(2017.05.23)

    1.立会照片 2.每个人的工作 每个成员的分工: 成员 今天已完成的工作 明天计划完成的工作 罗于婕 完善代码规范文档 辅助完善生词本 龚晓婷 界面优化  辅助开发新功能 林仕庄 界面图标不对齐bug ...

  6. 团队作业4——第一次项目冲刺(Alpha版本) 2017.4.23

    本次会议为第二次Scrum Meeting会议~ 由于本次会议项目经理召开时间为10:30,在五社区会五号楼召开,召开时长约30分钟,对昨天的工作进行了总结并分配了今天的任务. 1.站立式会议照片(拍 ...

  7. 2017.10.23 Java 面向对象深入学习---final 关键字、static关键字、匿名对象等

    今日内容介绍 1.final 关键字 2.static 关键字 3.匿名对象 4.内部类 5.包的声明与访问 6.访问修饰符 7.代码块 第一节课 01(面向对象)final关键字概念.avi 02: ...

  8. 23.centos7基础学习与积累-009-linux目录

    从头开始积累centos7系统运用 大牛博客:https://blog.51cto.com/yangrong/p5 linux目录的特点: 1. /是所有目录的顶点. 2. 目录结构像一颗倒挂的树. ...

  9. 2017.9.23 NOIP2017 金秋杯系列模拟赛 day1 T1

    回形遍历( calc .cpp/c/pas) 时间限制:1s内存 限制: 256MB [问题 描 述] 给出一个 n*m 的棋盘,按如下方式遍历,请问(x,y)往后 z 步走到的是哪个格子. [输入] ...

随机推荐

  1. access 随机选取数据

    access随机读取数时 用order  by  rnd(id)   发现每次获取的数据顺序都是一致的,必须要加上随机数才可以,如下: Random r = new Random();         ...

  2. C语言-知识点及学习路线

    最近进行了为期两周的C语言培训,把几年前学过的C语言又重新学习了一遍,然后根据学习的内容和过程,总结了一下学习路线.这是基本的C语言学习路线,相当于编程语言类的基础,再根据自己究竟是要做单片机开发,还 ...

  3. CodeForces 755C PolandBall and Forest (并查集)

    题意:给定每一点离他最远的点,问是这个森林里有多少棵树. 析:并查集,最后统计不同根结点的数目即可. 代码如下: #pragma comment(linker, "/STACK:102400 ...

  4. PHP 绘图技术

    1.图片格式:目前网站开发常见的图片格式有gif,jpg/jpeg,png ..... 区别: gif 图片压缩率高,但是只能显示256色,可能造成颜色的丢失,可以显示动画 jpg/jpeg 图片压缩 ...

  5. BNU Online Judge-34973-Liserious战队

    题目链接 http://www.bnuoj.com/bnuoj/problem_show.php?pid=34973 题目不难,很容易,不过不仔细看题可能你一直做不出,注意<<一共分为1~ ...

  6. javaweb入门实例---servlet例子

    1.编写servlet: TreeDataServlet.java package com.maggie.tree; import java.io.IOException; import javax. ...

  7. java解析XML,并生成文档

    一.Java中XML的四种方法 Java学习者须知:Java中XML的四种方法 java xml学习总结(4中方法的例子介绍) JDOM解析XML Dom4j解析XML

  8. flex stage.width 与stage.stageWidth的区别

    flex stage.width 与stage.stageWidth的区别: stage.width 是指舞台上的可视对象占据的尺寸 stage.stageWidth是指舞台设置的尺寸,与舞台上的元件 ...

  9. SQL2008实现数据库自动定时备份——维护计划

    在SQL Server中出于数据安全的考虑,所以需要定期的备份数据库.而备份数据库一般又是在凌晨时间基本没有数据库操作的时候进行,所以我们不可能要求管理员 每天守到晚上1点去备份数据库.要实现数据库的 ...

  10. Word常用实用知识1

    Word常用实用知识1 纯手打,可能有错别字,使用的版本是office Word 2013 转载请注明出处,谢谢. 快速输入日期(含格式) [插入]--[日期]   快速输入日期和时间(快捷键) 快速 ...