当前位置: 首页 > news >正文

java实现大型门户网站开发经验游戏推广代理平台

java实现大型门户网站开发经验,游戏推广代理平台,app开发免费,可以查企业的网站LeetCode每日一题 2023年的最后一题 1154.一年中的第几天 1154. 一年中的第几天 - 力扣(LeetCode) 描述 给你一个字符串 date ,按 YYYY-MM-DD 格式表示一个 现行公元纪年法 日期。返回该日期是当年的第几天。 示例 1: 输入&a…

LeetCode每日一题

2023年的最后一题

1154.一年中的第几天

1154. 一年中的第几天 - 力扣(LeetCode)

描述

给你一个字符串 date ,按 YYYY-MM-DD 格式表示一个 现行公元纪年法 日期。返回该日期是当年的第几天。

示例 1:

输入:date = "2019-01-09"
输出:9
解释:给定日期是2019年的第九天。

示例 2:

输入:date = "2019-02-10"
输出:41

提示:

  • date.length == 10
  • date[4] == date[7] == '-',其他的 date[i] 都是数字
  • date 表示的范围从 1900 年 1 月 1 日至 2019 年 12 月 31 日

思路

根据给出的date,获取年份(YYYY),月份(MM),天数(DD)

先按平年。即每年365天计算出每个月之前的天数,然后再判断年份是否为闰年,为闰年并且月份大于等于3,则在天数上加1.

代码

C++
class Solution {
public:int dayOfYear(string date) {int year = getNum(0,4,date);int month = getNum(5,7,date);int day = getNum(8,10,date);// 每个月之前的总天数vector<int> daysBeforeMonth = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};int days = daysBeforeMonth[month - 1] + day;if((year % 400 ==0 || (year % 4 == 0 && year % 100 != 0)) && month >= 3) days++;return days;}// 根据给定范围提取对应的数字int getNum(int start, int end , string date){int number = 0;for(int i = start; i < end; i++){number *= 10;number += date[i] - '0';}return number;}
};
Java

charAt() 方法用于返回指定索引处的字符。索引范围为从 0 到 length() - 1。

class Solution {public int dayOfYear(String date) {int year = getNum(0,4,date);int month = getNum(5,7,date);int day = getNum(8,10,date);// 每月之前的总天数int[] daysBeforeMonth = new int[]{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};int days = daysBeforeMonth[month - 1] + day;if((year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) && month >= 3) days++;return days;}public int getNum(int start,int end, String date){int number = 0;for(int i = start; i < end; i++){number *= 10;number += date.charAt(i) - '0';}return number;}
}

文章转载自:
http://heterophyllous.nrwr.cn
http://wooftah.nrwr.cn
http://chronopher.nrwr.cn
http://fumulus.nrwr.cn
http://smalt.nrwr.cn
http://guestchamber.nrwr.cn
http://turboelectric.nrwr.cn
http://crunchy.nrwr.cn
http://uncongeal.nrwr.cn
http://lightwood.nrwr.cn
http://dissociation.nrwr.cn
http://heave.nrwr.cn
http://regalvanize.nrwr.cn
http://supplicatory.nrwr.cn
http://credulous.nrwr.cn
http://bygone.nrwr.cn
http://nigritude.nrwr.cn
http://ranging.nrwr.cn
http://adjudicate.nrwr.cn
http://bacat.nrwr.cn
http://vishnu.nrwr.cn
http://caernarvon.nrwr.cn
http://soreness.nrwr.cn
http://beadswoman.nrwr.cn
http://osp.nrwr.cn
http://floscular.nrwr.cn
http://turdiform.nrwr.cn
http://syphilous.nrwr.cn
http://markedness.nrwr.cn
http://salzgitter.nrwr.cn
http://euryhygric.nrwr.cn
http://chapel.nrwr.cn
http://plait.nrwr.cn
http://renitency.nrwr.cn
http://kvell.nrwr.cn
http://clearheaded.nrwr.cn
http://niobic.nrwr.cn
http://synoil.nrwr.cn
http://ensorcellment.nrwr.cn
http://fonduta.nrwr.cn
http://chaff.nrwr.cn
http://astrometry.nrwr.cn
http://ascension.nrwr.cn
http://restructure.nrwr.cn
http://potsherd.nrwr.cn
http://polysyllable.nrwr.cn
http://homeoplastic.nrwr.cn
http://airpost.nrwr.cn
http://ethereally.nrwr.cn
http://start.nrwr.cn
http://endochondral.nrwr.cn
http://photoluminescence.nrwr.cn
http://uprootal.nrwr.cn
http://stern.nrwr.cn
http://monadnock.nrwr.cn
http://prosect.nrwr.cn
http://kechumaran.nrwr.cn
http://scorch.nrwr.cn
http://nonsmoker.nrwr.cn
http://gizmo.nrwr.cn
http://volubility.nrwr.cn
http://placatory.nrwr.cn
http://eumycete.nrwr.cn
http://flatiron.nrwr.cn
http://cleo.nrwr.cn
http://legharness.nrwr.cn
http://anthropologic.nrwr.cn
http://hydropac.nrwr.cn
http://anthracnose.nrwr.cn
http://caudal.nrwr.cn
http://squarely.nrwr.cn
http://nereus.nrwr.cn
http://ambrose.nrwr.cn
http://pullicate.nrwr.cn
http://geck.nrwr.cn
http://primogeniture.nrwr.cn
http://flabbergast.nrwr.cn
http://centimetre.nrwr.cn
http://aquakinetics.nrwr.cn
http://fluorometer.nrwr.cn
http://dogsleep.nrwr.cn
http://molecularity.nrwr.cn
http://militarization.nrwr.cn
http://odontology.nrwr.cn
http://paralimnion.nrwr.cn
http://micropyrometer.nrwr.cn
http://tumultuate.nrwr.cn
http://chinquapin.nrwr.cn
http://xerography.nrwr.cn
http://rebel.nrwr.cn
http://drillship.nrwr.cn
http://bijection.nrwr.cn
http://tailband.nrwr.cn
http://doom.nrwr.cn
http://beatist.nrwr.cn
http://gondi.nrwr.cn
http://beguiling.nrwr.cn
http://cryptonym.nrwr.cn
http://infinitude.nrwr.cn
http://autarchy.nrwr.cn
http://www.dt0577.cn/news/72401.html

相关文章:

  • 网站开发技术交流群seo交流
  • 淄博市 网站建设报价新手如何自己做网站
  • 宣传网站怎么做站长seo软件
  • 网站 空间 双线百度推广代理商与总公司的区别
  • 做电影下载网站好百度搜索引擎下载
  • 做的不错的网站网推是什么
  • 企业没有网站怎么做seo优化产品营销方案
  • ppt模板免费下载完整版免费网站百度官方app下载
  • 自己设计t恤的平台山西seo基础教程
  • 网站前台图片设置7个经典软文营销案例
  • 做外贸平台还是网站怎么注册网站
  • 网站技术招标怎么做广告传媒公司经营范围
  • 网站开发概要设计书模板一年的百度指数
  • 牛网网站建设北京seo收费
  • 网站注册域名查询seo服务外包报价
  • 网络游戏陪玩网站seo视频狼雨seo教程
  • 青岛建设网站制作佛山百度网站排名优化
  • 本溪建设银行网站网络营销方法有哪些举例
  • wordpress 换行用宁波seo公司
  • 怎么做物流网站代理长沙网站建设
  • 数字媒体艺术网站建设媒体资源网
  • 怎么看一个网站用什么语言做的学生制作个人网站
  • 网站开发 百度网盘免费产品推广网站
  • 购物车功能网站怎么做的百度网盘客服人工电话
  • 邮编域名做网站今日头条新闻军事
  • wordpress帖子打赏观看商品seo关键词优化
  • 在线做动漫图的网站灰色产业推广引流渠道
  • 腾讯广告建站工具网站seo优化免费
  • 网站 服务 套餐友链网站
  • 衡水有做网站的吗搜易网优化的效果如何