大家帮我看看我这错在哪,怎么打印出来1号,对不上星期
java吧
全部回复
仅看楼主
level 2
import java.util.Scanner;
public class x{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("请输入你要的年:");
int n = in.nextInt();
System.out.println("请输入你要的月:");
int y=in.nextInt();
int d=0;
for(int year=1900;year<n;year++){
if(year%4==0&&year%100!=0||year%400==0){
d=d
+3
66;
}else{
d=d+365;
}
}
for(int month=1;month<y;month++){
if(month==2){
if(n%4==0&&n%100!=0||n%400==0){
d=d+29;
}else{
d=d+28;
}
}
if(month==4||month==6||month==9||month==11){
d=d+30;
}else{
d=d+31;
}
}
d=d+1;
int s=d%7;
System.out.println(s);
System.out.println("日\t一\t二\t三\t四\t五\t六");
for(int i=1;i<=s;i++){
System.out.print("\t");
}
for(int i=1; i<=31;i++){
if(d%7==6){
System.out.print(i+"\n");
}else{
System.out.print(i+"\t");
}
d=d+1;
}
}
}
2018年08月04日 10点08分 1
level 2
我研究半个小时都不知道错在哪,不知道那算错啦
2018年08月04日 10点08分 2
level 4
报了什么错呀
2018年08月04日 10点08分 3
没报错,就是1号对不上星期。比如2018,8.1。对应星期三,我打印出来对应星期六
2018年08月04日 10点08分
level 9
问题解决了没有,可以联系我,3022298345
2018年08月04日 12点08分 4
1