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 步走到的是哪个格子. [输入] ...
随机推荐
- IO文件
在Windows下的路径分隔符和Linux下的路径分隔符是不一样的,当直接使用绝对路径时,跨平台会暴出“No such file or diretory”的异常. Separator: 比如说要在te ...
- 3)Javascript设计模式:Observer模式
Observer模式 var Observer = (function() { var instance = null; function Observe() { this.events = {} } ...
- CodeForces 755C PolandBall and Forest (并查集)
题意:给定每一点离他最远的点,问是这个森林里有多少棵树. 析:并查集,最后统计不同根结点的数目即可. 代码如下: #pragma comment(linker, "/STACK:102400 ...
- android模拟器网络设置(局域网)
Android模拟器如何设置DNS访问局域网内网站 我们需要用到android-sdk开发包中adb shell指令 见下图
- 四 APPIUM GUI讲解(Windows版)
Windows版本的APPIUM GUI有以下图标或者按钮: ·Android Settings - Android设置按钮,所有和安卓设置的参数都在这个里面 ·General Settings – ...
- xshell安装运行时提示缺少mfc110.dll
下载最新的mfc110.dll文件 https://pan.baidu.com/share/link?shareid=1932421734&uk=1784696518&app=zd 之 ...
- animate动画被锁在队列中不动怎么解决
[示例]: function scroll_to(obj){ $('html,body').animate({scrollTop:obj.position().top},700) ...
- HTML 多媒体、Object 元素、音频、视频
Web 上的多媒体指的是音效.音乐.视频和动画. 现代网络浏览器已支持很多多媒体格式. 什么是多媒体? 多媒体来自多种不同的格式.它可以是您听到或看到的任何内容,文字.图片.音乐.音效.录音.电影.动 ...
- jQuery disabled 元素
http://www.jb51.net/article/19342.htm 在jquery中可以通过jqueryObj.attr("disabled","disabled ...
- Bootstrap入门(十五)组件9:面板组件
Bootstrap入门(十五)组件9:面板组件 虽然不总是必须,但是某些时候你可能需要将某些 DOM 内容放到一个盒子里.对于这种情况,可以试试面板组件. 1.基本实例 2.带标题的面板 3.情景效果 ...