用中间变量做这个题

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. svn 安装网站

    1.svn插件 http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240

  2. 1)Linux学习笔记:crontab命令

    crond简介 crond是linux下用来周期性的执行某种任务或等待处理某些事件的一个守护进程 配置文件 ``` SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin: ...

  3. 会话Cookie及session的关系(Cookie & Session)

    会话Cookie及session的关系(Cookie & Session) 在通常的使用中,我们只知道session信息是存放在服务器端,而cookie是存放在客户端.但服务器如何使用sess ...

  4. iOS 之 const

    const int a与 int const a一样. const int *a ;//指针可以修改,指向常整形的指针 int* const a;// 常指针, int* 作为一个整体被限制, 所以指 ...

  5. SQL迅速增加表中记录语句

    很多时候我么需要为表中疯狂增加N条记录,那么我们该使用什么语句实现该功能呢?如下: insert into 表名(字段1,字段2,字段3....)  select 字段1,字段2,字段3.... fr ...

  6. thinkPHP 视图

    一.模板的使用        a.规则        模板文件夹下[TPL]/[分组文件夹/][模板主题文件夹/]和模块名同名的文件夹[Index]/和方法名同名的文件[index].html(.tp ...

  7. HDU-4861-Couple doubi(数学题,难懂!难懂!)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4861 这个题只能说没弄懂,感觉很难,看博客也看不懂,只能,多看几次,看能不能有所突破了. 代码的话只有 ...

  8. Java线程:线程交互

    一.基础知识 java.lang.Object的类的三个方法: void notify():唤醒在此对象监视器上等待的单个线程. void notifyAll():唤醒在此对象监视器上等待的所有线程. ...

  9. Java的IO操作中有面向字节(Byte)和面向字符(Character)两种方式

    解析:Java的IO操作中有面向字节(Byte)和面向字符(Character)两种方式.面向字节的操作为以8位为单位对二进制的数据进行操作,对数据不进行转换,这些类都是InputStream和Out ...

  10. ORACLE的Dead Connection Detection浅析

    在复杂的应用环境下,我们经常会遇到一些非常复杂并且有意思的问题,例如,我们会遇到网络异常(网络掉包.无线网络断线).客户端程序异常(例如应用程序崩溃Crash).操作系统蓝屏.客户端电脑掉电.死机重启 ...