2017-2-23 C#基础 中间变量
用中间变量做这个题
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#基础 中间变量的更多相关文章
- 2017/05/23 java 基础 随笔
1.多态的好处: a.提高了代码的维护性(继承保证) b.提高了代码的扩展性(由多态保证) package com.huawei; public class Demo2 { public static ...
- 2017 Android 面试题 [ 基础与细节 ]
2017 Android 面试题 [ 基础与细节 ] 感谢@chuyao抛出的这些问题,平时业务代码写多了,很多基础的东西变得含糊不清了,这次裸辞出来找工作确实没有之前顺利,顺便求上海Android开 ...
- 总结 Date 2017.09.23
总结 Date 2017.09.23 <1>统计数字 某次科研调查时得到了n个自然数,每个数均不超过1500000000(1.5*10^9).已知不相同的数不超过10000个,现在需要统计 ...
- SNS团队第二次站立会议(2017.04.23)
一.当天站立式会议照片 本次会议主要内容:汇报工作进度,根据完成情况调整进度 二.每个人的工作 成员 今天已完成的工作 明天计划完成的工作 罗于婕 梳理清楚数据的每个类型和数据项 具体落实把相关数据 ...
- SNS团队Beta阶段第二次站立会议(2017.05.23)
1.立会照片 2.每个人的工作 每个成员的分工: 成员 今天已完成的工作 明天计划完成的工作 罗于婕 完善代码规范文档 辅助完善生词本 龚晓婷 界面优化 辅助开发新功能 林仕庄 界面图标不对齐bug ...
- 团队作业4——第一次项目冲刺(Alpha版本) 2017.4.23
本次会议为第二次Scrum Meeting会议~ 由于本次会议项目经理召开时间为10:30,在五社区会五号楼召开,召开时长约30分钟,对昨天的工作进行了总结并分配了今天的任务. 1.站立式会议照片(拍 ...
- 2017.10.23 Java 面向对象深入学习---final 关键字、static关键字、匿名对象等
今日内容介绍 1.final 关键字 2.static 关键字 3.匿名对象 4.内部类 5.包的声明与访问 6.访问修饰符 7.代码块 第一节课 01(面向对象)final关键字概念.avi 02: ...
- 23.centos7基础学习与积累-009-linux目录
从头开始积累centos7系统运用 大牛博客:https://blog.51cto.com/yangrong/p5 linux目录的特点: 1. /是所有目录的顶点. 2. 目录结构像一颗倒挂的树. ...
- 2017.9.23 NOIP2017 金秋杯系列模拟赛 day1 T1
回形遍历( calc .cpp/c/pas) 时间限制:1s内存 限制: 256MB [问题 描 述] 给出一个 n*m 的棋盘,按如下方式遍历,请问(x,y)往后 z 步走到的是哪个格子. [输入] ...
随机推荐
- sublime text2的插件熟悉
今天加班,开会.于是整理下sublime text的插件. 1.安装了tag插件.负责html的格式化.从百度云下载了文件,放入了插件包的目录下. 2.启用了alignment 快捷键 ctr+alt ...
- Java的进制转换操作(十进制、十六进制、二进制)
2014-05-06 17:34 吴文付 最近由于工作上的需要,遇到进制转换的问题.涉及到的进制主要是 十进制,十六进制,二进制中间的转换. 这里整理一下.具体的计划为:封装一个转换类,一个测试类. ...
- nginx代理tomcat后,tomcat获取真实(非proxy,非别名)nginx服务端ip端口的解决方案
nginx代理tomcat后,tomcat获取服务端ip端口的解决方案 1.注意修改nginx配置代理,标红地方 #user nginx; worker_processes ; error_log l ...
- 获取IE浏览器关闭事件
//关闭浏览器时才会触发此操作,刷新页面不执行 //n 检测鼠标相对于用户屏幕的水平位置 - 网页正文部分左:求出鼠标在当前窗口上的水平位置(参照:当前窗口右上角为0.0坐标) //m 网页正文全文宽 ...
- 【转】sql语句的优化分析
开门见山,问题所在 sql语句性能达不到你的要求,执行效率让你忍无可忍,一般会时下面几种情况. 网速不给力,不稳定. 服务器内存不够,或者SQL 被分配的内存不够. sql语句设计不合理 没有相应的索 ...
- python 自动化之路 day 13
本节内容参考博客: http://www.cnblogs.com/wupeiqi/articles/5132791.html http://www.cnblogs.com/wupeiqi/articl ...
- IOS Cell重用机制
重用机制: -(UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *) ...
- JS的组成部分、引入页面的方法以及命名规范
JS的组成部分.引入页面的方法以及命名规范 一.页面是由三部分组成 1)html标签(超文本标记语言) 2)css样式(层叠样式表) 3)javascript脚本编程语言(动态脚本语言) 二.将c ...
- iOS 准备
iOS 编程知识点 iOS 基础知识点 iOS 之 系统机制 Xcode 使用技巧 Mac 使用技巧 iOS 之 英语 iOS 之 编外知识点 iOS 知识库链接
- 前言《iOS网络高级编程:iPhone和iPad的企业应用开发》(书籍学习)
本书内容: 在客户端设备与服务器之间执行HTTP请求 管理客户端设备与服务器之间的数据负载 处理HTTP请求的错误 保护网络通信 改进网络通信的性能 执行Socket层的通信 实现推送通知 单个设备上 ...