用中间变量做这个题

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. 一种新的隐藏-显示模式诞生——css3的scale(0)到scale(1)

    .dropdown-menu {  background: rgba(255, 255, 255, 0.98) none repeat scroll 0 0;  box-shadow: 0 1px 2 ...

  2. java语法:字符串数组的赋值

    字符串数组怎么赋值呢? 首先当然得先定义啦:String infoPack[] : 然后想当然的以为在for循环里,new一个数组, String infoPack[i] = imgurls; 事实证 ...

  3. 4、安卓数据存储——sqlite

    朋友圈里的每一个消息体里面的数据,当下拉刷新从服务器下载数据包后,存入sqlite:用户名.图片url.点赞.评论等等.上拉加载的时候,从数据库里取出最近的5条数据加载到朋友圈上. Android通过 ...

  4. 【Xilinx-Petalinux学习】-00-开始

    基于自己的ZYNQ板子,在上面运行petalinux,已经搞得稳定了,之后详细记录. 现在功能:QSPI启动u-boot和kernel,vdma.tpg.osd.vtc等IP模块在Linux下的驱动, ...

  5. mobile meta iphone

    <!doctype html> <html> <head> <title>iOS touch test ( Multi-touch )</titl ...

  6. java_web学习(1)理解JavaBean

    JavaBean简介       JavaBean是一种特殊的 Java 类,它遵从一定的设计模式,开发工具和其他组件可以根据这种模式来调用JavaBean. JavaBean可以设计得像Swing组 ...

  7. mysql数据库锁定机制

    前言 为了保证数据的一致完整性,任何一个数据库都存在锁定机制.锁定机制的优劣直接应想到一个数据库系统的并发处理能力和性能,所以锁定机制的实现也就 成为了各种数据库的核心技术之一.本章将对MySQL中两 ...

  8. jquery换肤

    <script src="script/jquery-2.1.0.js"></script>      <link href="style/ ...

  9. cygwin下配置alias

    主要是cygwin下的盘符映射关系容易忘,直接用mount命令: 所以,找到E:\cygwin64\home\Administrator下面的.bashrc,添加alias.如下:

  10. IIS8中添加WCF支持几种方法小结[图文]

    方法一 最近在做Silverlight,Windows Phone应用移植到Windows 8平台,在IIS8中测试一些传统WCF服务应用,发现IIS8不支持WCF服务svc请求,后来发现IIS8缺少 ...