当前位置:网站首页>渣渣学习之路(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]);
}
}
}
边栏推荐
- UDP message structure
- Read pictures and convert them to show different color spaces
- Preorder traversal of binary tree
- Markdown syntax and common shortcuts
- 阿拉伯数字转中文
- [force buckle] flip binary tree
- 《PyTorch深度学习实践》-B站 刘二大人-day5
- Visual saliency based visual gaze estimation
- [force buckle] realize queue with stack
- Perceive the attention status of users on smart phones
猜你喜欢

Restclient query document

斑点检测 记录

Color histogram grayscale image & color image

虚拟现实中的眼睛跟踪

吴恩达机器学习第8-9章

Positional Change of the Eyeball During Eye Movements: Evidence of Translatory Movement眼球运动过程中眼球的位

通過VOR深度估計解决三維注視交互中的目標模糊問題

DSL realizes automatic completion query

2022/07/12 learning notes (day05) cycle

《PyTorch深度学习实践》-B站 刘二大人-day6
随机推荐
Seachest utilities tool enables your hard disk to consume less power and live longer
Learning video saliency from human gaze using candidate selection
Dual tone sorting of CUDA and large arrays
Markdown syntax and common shortcuts
ORACLE分组排序后获取第一条和最后一条值
Automatic completion & (custom) Pinyin word Separator &
吴恩达机器学习第10-11章
Typescript learning
网络中的一些基本概念
Get the current month, day, hour, minute, second and week, and update them in real time
手把手搭建家用 NAS 全能服务器(1)| 配置选择及准备
Mapping index attribute & operation of creating index
Preparation of blast Library of rust language from scratch (2) -- detailed explanation of Blas matrix format
Experiment 3 inheritance and derived classes
山西省第二届网络安全技能大赛(企业组)部分赛题WP(一)
Part of the second Shanxi Network Security Skills Competition (Enterprise Group) WP (II)
Key points of embedded C language (const, static, volatile, bit operation)
Busybox 1.21.1 has udpsvd function, which can be compiled successfully without interfering with the local busybox method
Learning non posture gaze deviation with head movement
Some problems encountered in work