当前位置:网站首页>渣渣学习之路(1)输出某年某月的日历页
渣渣学习之路(1)输出某年某月的日历页
2022-07-17 05:20:00 【渣渣今天学废了吗】
Java输出某年某月的日历页
通过键盘输入日期传递函数中输出日历页:
package dy;
import java.util.Calendar;
import java.util.Scanner;
public class DDy{
public static void main(String args[]){
Scanner in=new Scanner(System.in);
System.out.println("请输入年份:");
int year=in.nextInt();
System.out.println("请输入月份:");
int month=in.nextInt();
in.close();
Calendar 日历=Calendar.getInstance();
日历.set(year,month,1);
int 星期几=日历.get(Calendar.DAY_OF_WEEK)-1;
int day=0;
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
day=31;
System.out.println("此月共有:"+day+'天');
}
else
if(month==4||month==6||month==9||month==11){
day=30;
System.out.println("此月共有:"+day+'天');
}
else
if(month==2){
if(year%4==0&&year%100!=0||year%400==0){
day=29;
System.out.println("此月共有:"+day+'天');
}
else
day=28;
System.out.println("此月共有:"+day+'天');
}
String c[]=new String[星期几+day];
for(int j=0;j<星期几;j++){
c[j]="";
}
for(int j=星期几,n=1;j<星期几+day;j++){
c[j]=String.valueOf(n);
n++;
}
System.out.printf("%14c%14c%14c%14c%14c%14c%14c\n",'日','一','二','三','四','五','六');
for(int j=0;j<c.length;j++){
if(j%7==0&&j!=0)
System.out.printf("\n");
System.out.printf("%5s",c[j]);
}
}
}
边栏推荐
- Preparation of blast Library of rust language from scratch (2) -- detailed explanation of Blas matrix format
- Daily eye contact detection uses unsupervised gaze target detection
- Robot stitching gesture recognition and classification
- Perceive the attention status of users on smart phones
- 三维凝视估计,没有明确的个人校准2018
- ANAME
- [force buckle] ring list II
- 阿拉伯数字转中文
- Cygwin cooperates with listary to switch the current directory and quickly open it
- Color histogram grayscale image & color image
猜你喜欢

Learning non posture gaze deviation with head movement

翻转链表

5-17 hidden student services of Shaanxi University of science and technology

Learning video saliency from human gaze using candidate selection

斑点检测 记录

Spot detection record

Experiment class II and object definition initialization

Read pictures and convert them to show different color spaces

Cygwin cooperates with listary to switch the current directory and quickly open it

Restapi implementation of automatic completion & case implementation (search box input for automatic completion)
随机推荐
Leetcode string
Learning video saliency from human gaze using candidate selection
自下而上和自上而下的注意力:不同的过程和重叠的神经系统 2014sci
[force buckle] realize queue with stack
TCP协议
wireshark抓包:错误分析
山西省第二届网络安全技能大赛(企业组)部分赛题WP(二)
Bottom up and top-down attention: different processes and overlapping nervous systems 2014sci
网络中的一些基本概念
工作中遇到的一些问题
《PyTorch深度学习实践》-B站 刘二大人-day5
山西省第二届网络安全技能大赛(企业组)部分赛题WP(一)
Key points of embedded C language (const, static, volatile, bit operation)
Positional Change of the Eyeball During Eye Movements: Evidence of Translatory Movement眼球运动过程中眼球的位
吴恩达机器学习第3-4章
Learning non posture gaze deviation with head movement
Convert PNG with transparency to C array
Get the current month, day, hour, minute, second and week, and update them in real time
[force buckle] flip binary tree
翻转链表