求解 输入两个年和月,计算两个年和月之间相差几年几月.输出方式:3年7月给点思路,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 int months = Math.abs((year1*12 + month1) - (year2*12 + month2))年数:months/12月数:months%12 int months = Math.abs((year1*12 + month1) - (year2*12 + month2))年数:months/12月数:months%12最简单的办法嘛,接分 class Test{ public static void cal(String year1,String month1,String year2,String month2){ int month=Math.abs((Integer.parseInt(year1)*12+Integer.parseInt(month1))-(Integer.parseInt(year2)*12+Integer.parseInt(month2))); System.out.print(month/12+"年"); System.out.println(month%12+"月"); } public static void main(String[] args){ //djs.cal(args[0],args[1],args[2],args[3]); Test.cal("2000","3","2003","10"); }} int months = Math.abs((year1*12 + month1) - (year2*12 + month2))年数:months/12月数:months%12================================顶 我居然想到要算毫秒去了 汗。。 求教这个java 读文件程序错在哪里 set转换数组或map输出值不一致 关于Exception的问题 看看这个面试题!!!! 高分:如何将固定格式 excel 转化 xml 流对文件的操作的问题 shape程序,不太理解!多次运行产生不同结果! 我常去的Java网站www.it315.org,不知是否有vc的免费视频下载,别的网站呢 一个jbuider数据库commit的问题 ~~进门就送分!~~ 如何执行包含多语种的SQL语句呢? 集合类中列表也数组之间的转换 请高手指点,如果hashmap不知道object key 如何得到hashmap里面的值?
年数:months/12
月数:months%12
年数:months/12
月数:months%12最简单的办法嘛,接分
public static void cal(String year1,String month1,String year2,String month2){
int month=Math.abs((Integer.parseInt(year1)*12+Integer.parseInt(month1))-(Integer.parseInt(year2)*12+Integer.parseInt(month2)));
System.out.print(month/12+"年");
System.out.println(month%12+"月");
}
public static void main(String[] args){
//djs.cal(args[0],args[1],args[2],args[3]);
Test.cal("2000","3","2003","10");
}
}
年数:months/12
月数:months%12
================================
顶 我居然想到要算毫秒去了 汗。。