1075 -- 第几天?
来源:互联网 发布:矩阵关联分析法 编辑:程序博客网 时间:2024/06/02 10:10
第几天?
Time Limit:1000MS Memory Limit:65536K
Total Submit:99 Accepted:55
Description
给定一个日期,输出这个日期是该年的第几天。
Input
输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的。
Output
对于每组输入数据,输出一行,表示该日期是该年的第几天。
Sample Input
1985/1/202006/3/12
Sample Output
2071
Source
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AK1075 { class Program { static bool leapyear(int n) { if ((n % 4 == 0 && n % 100 != 0) || n % 400 == 0) return true; return false; } static void Main(string[] args) { string sb; while ((sb = Console.ReadLine()) != null) { int x = 0, y = 0;//前面这一大串就是要解决输入问题,真尼玛坑 for (int i = 0; i < sb.Length; i++) { if (sb[i] == '/' && x == 0) x = i; if (sb[i] == '/' && x != 0) y = i; } int year = int.Parse(sb.Substring(0, x)); int month = int.Parse(sb.Substring(x + 1, y - x - 1)); int day = int.Parse(sb.Substring(y + 1, sb.Length - y - 1)); //Console.WriteLine(year + " " + month + " " + day); int[] a = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };//非闰年 int[] b = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };//闰年 int sum = 0; if (leapyear(year)) { for (int i = 0; i < month - 1; i++) sum += b[i]; sum += day; } else { for (int i = 0; i < month - 1; i++) sum += a[i]; sum += day; } Console.WriteLine(sum); } } } }
0 0
- 1075 -- 第几天?
- 第几天
- 【第几天?】
- 第几天?
- 第几天
- 第几天?
- 第几天
- 第几天
- 第几天?
- 第几天
- 第几天
- 第几天?
- 第几天
- 第几天?
- 第几天
- 第几天
- 第几天?
- 第几天?
- 边线设置为阴影效果
- 1074 -- 人见人爱A^B
- 代码格式化工具 sourceInsight editplus ultraedit keil
- C++类中成员变量的初始化
- 鼠标拖拽事件响应
- 1075 -- 第几天?
- C/C++内存泄漏及检测
- 1076 -- Encoding
- Ubuntu 14.04 配置 LAMP+phpMyAdmin PHP(5.5.9)开发环境
- java中双缓冲
- 从QQ网站中提取的纯JS省市区三级联动
- 1077 -- The 3n + 1 problem
- HTML5 localStorage
- 关于union和join区别和联系