当前位置: 首页 > 编程日记 > 正文

12小时进制的时间输出的编辑代码

关于时间输出的编辑代码个人思考了很久,包括顺序,进位之类的,求完善和纠错

public class yunsuanfu {public static  void main(String[] arg){double t=2;int h=38;int m=100;int s=100;if(s>60){m=(s/60)+m;s=s%60;}if (m>60){h=(m/60)+h;m=m%60;}if(h>12){t=t+(0.5*(h/12));h=h%12;}System.out.println(t+"天"+h+"点"+m+"分"+s+"秒");

时间代码首先要注意的是对“if”   和  “else”的正确运用,以及对运算符的掌握;其次是要注意顺序问题,要按照“秒,分,点,天”的顺序输出,这样可以防止没有进位的问题。
            在“t”这个变量中,我用的是double,是因为这个时间代码是12小时制的,而我省略了“下午输出PM”这一环节,所以到了下午天数就会变成0.5的形式。

转载于:https://www.cnblogs.com/doubiqi/p/5013804.html

相关文章:

c++每调用一次函数+1_每个开发人员都应该知道的一些很棒的现代C ++功能

c每调用一次函数1As a language, C has evolved a lot.作为一种语言,C 已经发展了很多。 Of course this did not happen overnight. There was a time when C lacked dynamism. It was difficult to be fond of the language.当然,这并非一overnight而…

Linux ISCSI配置

一、简介 iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的、可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择。iSCS…

样式集(三)成功页面样式模板

上图&#xff1a; 代码&#xff1a; <!--pages/result/result.wxml--> <view><image class"scc" src"/img/scc.png"></image><view class"resuil">办理成功</view> </view> <view class"btn…

C#中Request.servervariables参数

整理一下&#xff0c;我在asp.net下遍历的Request.servervariables这上集合&#xff0c;得出的所有参数如下&#xff1a; &#xff1a; Request.ServerVariables["ALL_HTTP"] 客户端发送的http所有报头信息 返回例&#xff1a;HTTP_CACHE_CONTROL:max-age0 HTT…

打开浏览器的包 node_如何发布可在浏览器和Node中使用的软件包

打开浏览器的包 nodeWhen you create a package for others to use, you have to consider where your user will use your package. Will they use it in a browser-based environment (or frontend JavaScript)? Will they use it in Node (or backend JavaScript)? Or bot…

存储过程中SELECT与SET对变量赋值

Create proc insert_bookparam1char(10),param2varchar(20),param3money,param4moneyoutputwith encryption---------加密asinsert into book(编号,书名,价格)Values(param1,param2,param3)select param4sum(价格) from bookgo执行例子&#xff1a;declare total_price moneyex…

AngularJs $resource 高大上的数据交互

$resource 创建一个resource对象的工厂函数&#xff0c;可以让你安全的和RESFUL服务端进行数据交互。 需要注入 ngResource 模块。angular-resource[.min].js 默认情况下&#xff0c;末尾斜杠&#xff08;可以引起后端服务器不期望出现的行为&#xff09;将从计算后的URL中剥离…

样式集(四)搜索框样式

上图&#xff1a; 代码&#xff1a; // pages/search/search.js var textPage({data: {input_val:"",list:[]},input_p(e){this.setData({input_val:e.detail.value})},onLoad: function (options) {}, }) <view classpage_row bindtap"suo"><vi…

初步了解React Native的新组件库firstBorn

first-born is a React Native UI Component Framework, which follows the design methodology Atomic Design by Brad Frost.first-born是React Native UI组件框架&#xff0c;它遵循Brad Frost的设计方法Atomic Design 。 Version 1.0.0 was recently published as an npm …

less里面calc() 语法

转载 Less的好处不用说大家都知道&#xff0c;确实让写CSS的人不在痛苦了&#xff0c;最近我在Less里加入calc时确发现了有点问题&#xff0c;我在Less中这么写&#xff1a;  div {  width : calc(100% - 30px);  }  结果Less把这个当成运算式去执行了&#xff0c;结果…

基于XMPP的IOS聊天客户端程序(XMPP服务器架构)

最近看了关于XMPP的框架&#xff0c;以文本聊天为例&#xff0c;需要发送的消息为&#xff1a; <message type"chat" from"kangserver.com" to"testserver.com"> <body>helloWord</body> </message> …

小程序云开发,判断数据库表的两个字段匹配 云开发数据库匹配之 and 和 or 的配合使用

云开发数据库匹配之 and 和 or 的配合使用 代码&#xff1a; // 获取成员消息onMsg2() {let that thiswx.cloud.init({env: gezi-ofhmx})const DB wx.cloud.database()const _ DB.command;var aa "1"var bb "2"DB.collection(message_logging).where…

react引入多个图片_重新引入React:v16之后的每个React更新都已揭开神秘面纱。

react引入多个图片In this article (and accompanying book), unlike any you may have come across before, I will deliver funny, unfeigned and dead serious comic strips about every React update since v16. It’ll be hilarious, either intentionally or unintention…

75. Find Peak Element 【medium】

75. Find Peak Element 【medium】 There is an integer array which has the following features: The numbers in adjacent positions are different.A[0] < A[1] && A[A.length - 2] > A[A.length - 1].We define a position P is a peek if: A[P] > A[P-1…

云开发地图标记导航 云开发一次性取所有数据

地图取 elx 表格的经纬度数据&#xff0c;存到云开发数据库里面&#xff0c;然后标记在地图上&#xff0c;点击地图的标记可以实现路线规划&#xff0c;导航&#xff0c;拨打电话。 elx数据格式如下&#xff1a; 云开发的数据库不能直接导入elx&#xff0c;所以需要转换为csv文…

未能加载文件或程序集“Report.Basic”或它的某一个依赖项。试图加载格式不正确的程序...

出现问题如下&#xff1a; 解决办法&#xff1a; 这是由于没有开启32位程序兼容模式 具体操作如下&#xff1a;找到对应的程序池--------高级设置-------修改“启用32位应用程序”状态修改为true 转载于:https://www.cnblogs.com/OliverQin/p/5018575.html

flutter开发小程序_为什么我认为Flutter是移动应用程序开发的未来

flutter开发小程序I dabbled a bit in Android and iOS development quite a few years back using Java and Objective-C. After spending about a month working with both of them, I decided to move on. I just couldn’t get into it.几年前&#xff0c;我使用Java和Obje…

小程序获取图片的宽高

代码&#xff1a; imgInfo(url){wx.getImageInfo({src: url,success (res) {console.log(res.width)console.log(res.height)return {width:res.width,height:res.height}}})},

凯撒密码、GDP格式化输出、99乘法表

1.恺撒密码的编码 plaincode input(明文&#xff1a;)print(密文&#xff1a;,end)for i in plaincode: print(chr(ord(i)3),end) 2.国家名称 GDP总量&#xff08;人民币亿元&#xff09; 中国 &#xffe5;765873.4375澳大利亚 &#xffe5; 78312.4375&#xff08;国家名称左…

random类的使用

小栗子a如下: string[] punch new[] { "石头", "剪刀", "布" }; string myPunch; public string MyPunch{get{Random random new Random();int Index random.Next(3);myPunch punch[Index].ToString();return myPunch;}} 转载于:https://ww…

如何使用C#在ASP.NET Core中轻松实现QRCoder

by Yogi由瑜伽士 如何使用C&#xff03;在ASP.NET Core中轻松实现QRCoder (How to easily implement QRCoder in ASP.NET Core using C#) QRCoder is a very popular QR Code implementation library written in C#. It is available in GitHub. Here I am going to implement…

简述软件配置管理

http://blog.csdn.net/zhangmike/article/details/470477本文用菊子曰发布转载于:https://www.cnblogs.com/sdsunjing/p/5019791.html

startActivityForResult和setResult详解

startActivityForResult和setResult详解 原文:startActivityForResult和setResult详解startActivityForResult与startActivity的不同之处在于&#xff1a;1、startActivity( ) 仅仅是跳转到目标页面&#xff0c;若是想跳回当前页面&#xff0c;则必须再使用一次startActivity( …

小程序瀑布流实现

实现思路&#xff1a;把图片分成两排&#xff0c;创建两个数组&#xff0c;计算总数组中图片的宽高&#xff0c;对比上一个图片和当前的图片高度&#xff0c;低的就给另一个数组添加。效果图&#xff1a; 上代码&#xff1a; // miniprogram/pages/find/index.js const app g…

Webhooks上的一个简单方法:恐吓现在停止

Webhook.Webhook。 It sounds like what happens when you cross a spider and a pirate. In the world of the internet though, webhooks are something completely different. Webhooks help connect services together.听起来就像当您越过蜘蛛和海盗时会发生什么。 但是&a…

12.MySql关于获取当前时间的三个函数

这三个函数都是获取当前时间的&#xff0c;获取的详细格式如下图所示&#xff0c;可以根据需要来选用。 转载于:https://www.cnblogs.com/Nick-Hu/p/7566805.html

微信小程序云开发,使用阿里云短信服务,搜索员工生日定期发送短信。

相关API文档地址&#xff1a; 阿里云短信服务API文档地址 小程序云开发云函数正则匹配API文档地址 小程序云开发云函数定时触发器 1.登录阿里云&#xff0c;购买短信服务并添加签名和模板 2.&#xff0c; 登录阿里云&#xff0c;鼠标放在右上角的头像图标就会显示 AccessKey…

信息安全系统设计基础家庭作业

《深入理解计算机系统》家庭作业 * 8.9 答案&#xff1a; 进程对 是否并发 AB 否 AC 是 AD 是 BC 是 BD 是 CD 是 * 8.10 答案&#xff1a; A. 调用一次&#xff0c;返回两次&#xff1a; fork B. 调用一次&#xff0c;从不返回&#xff1a; execve, longjmp C. 调…

css游戏代码_介绍CSSBattle-第一个CSS代码搜寻游戏

css游戏代码by kushagra gour由kushagra gour 介绍CSSBattle-第一个CSS代码搜寻游戏 (Introducing CSSBattle — the first CSS code-golfing game) If you are learning Web development or are already a professional Web developer, there is a very high chance you have…

IOS手机全屏长按识别二维码HTML代码

代码段作用讲解&#xff1a; 1. 二维码的全屏样式, opacity: 0; 透明样式&#xff0c; touch-callout: none; -webkit-touch-callout: none; -ms-touch-callout: none; -moz-touch-callout: none; 禁止IOS默认长按事件 .codePage {position: absolute;touch-callout: none;…