第一天
Posted daimazhishen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第一天相关的知识,希望对你有一定的参考价值。
#include<iostream>
using namespace std;
int main()
int cock, hen, chicken;
for (cock = 1; cock < 20; cock++)
for (hen = 1; hen < 33; hen++)
chicken = 100 - cock - hen;
if (cock * 5 + hen * 3 + chicken / 3 == 100)
cout << cock << \' \' << hen << \' \' << chicken << endl;
return 0;
#include<iostream>
using namespace std;
int main()
int a, b, c;
for (a = 1; a <= 5; a++)
for (b = 1; b <= 5; b++)
for (c = 1; c <= 5 && a != b; c++)
if (c != a && c != b)
cout << "A:" << a << \' \' << "B:" << b << \' \' << "C:" << c << endl;;
return 0;
java 知道月份怎么获取第一天 最后一天
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class Test
/**
* 获取某月的最后一天
* @Title:getLastDayOfMonth
* @Description:
* @param:@param year
* @param:@param month
* @param:@return
* @return:String
* @throws
*/
public static String getLastDayOfMonth(int year,int month)
Calendar cal = Calendar.getInstance();
//设置年份
cal.set(Calendar.YEAR,year);
//设置月份
cal.set(Calendar.MONTH, month-1);
//获取某月最大天数
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
//设置日历中月份的最大天数
cal.set(Calendar.DAY_OF_MONTH, lastDay);
//格式化日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String lastDayOfMonth = sdf.format(cal.getTime());
return lastDayOfMonth;
/**
* 获取这个月的最后一天
* @Title:getLastDayOfCurrentMonth
* @Description:
* @param:@param year
* @param:@param month
* @param:@return
* @return:String
* @throws
*/
public static String getLastDayOfCurrentMonth()
Calendar cal = Calendar.getInstance();
//获取某月最大天数
int lastDay = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
//设置日历中月份的最大天数
cal.set(Calendar.DAY_OF_MONTH, lastDay);
//格式化日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String lastDayOfMonth = sdf.format(cal.getTime());
return lastDayOfMonth;
/**
* 获取某月的第一天
* @Title:getLastDayOfMonth
* @Description:
* @param:@param year
* @param:@param month
* @param:@return
* @return:String
* @throws
*/
public static String getFirstDayOfMonth(int year,int month)
Calendar cal = Calendar.getInstance();
//设置年份
cal.set(Calendar.YEAR,year);
//设置月份
cal.set(Calendar.MONTH, month-1);
//获取某月最大天数
int lastDay = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
//设置日历中月份的最大天数
cal.set(Calendar.DAY_OF_MONTH, lastDay);
//格式化日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String lastDayOfMonth = sdf.format(cal.getTime());
return lastDayOfMonth;
/**
* 获取这个月的第一天
* @Title:getFirstDayOfCurrentMonth
* @Description:
* @param:@param year
* @param:@param month
* @param:@return
* @return:String
* @throws
*/
public static String getFirstDayOfCurrentMonth()
Calendar cal = Calendar.getInstance();
//获取某月最大天数
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
//设置日历中月份的最大天数
cal.set(Calendar.DAY_OF_MONTH, lastDay);
//格式化日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String lastDayOfMonth = sdf.format(cal.getTime());
return lastDayOfMonth;
/**
* @Title:main
* @Description:
* @param:@param args
* @return: void
* @throws
*/
public static void main(String[] args)
String lastDay = getLastDayOfMonth(2014,2);
System.out.println("获取2014年2月的最后一天:" + lastDay);
String currentLDay= getLastDayOfCurrentMonth();
System.out.println("获取本月的最后一天:" + currentLDay);
String firstDay = getFirstDayOfMonth(2014,2);
System.out.println("获取2014年2月的第一天:" + firstDay);
String currentFDay= getFirstDayOfCurrentMonth();
System.out.println("获取本月的第一天:" + currentFDay);
传上来的代码真难看,不知道怎么发文件,我给你截一张图
参考技术A 月份的第1天,肯定是1日,,,,最后一天可以用下月1日的前一天取得,,,,,JAVA内部也有方法,和自己处理的结果是一样的。 参考技术B import java.util.Calendar;import java.util.Date;
public class CalenderTest
static Calendar calendar = null;
public static void main(String[] args)
calendar = Calendar.getInstance();
System.out.println(FirstDay(2));
System.out.println(LastDay(2));
public static Date FirstDay(int month)
calendar.set(Calendar.MONTH, month-1);
int maxday =calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, maxday);
return calendar.getTime();
public static Date LastDay(int month)
calendar.set(Calendar.MONTH, month-1);
int minday =calendar.getActualMinimum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, minday);
return calendar.getTime();
//
Mon Feb 29 11:20:38 CST 2016
Mon Feb 01 11:20:38 CST 2016
以上是关于第一天的主要内容,如果未能解决你的问题,请参考以下文章