查看:1111 回复:3
发表于 2008-7-25 23:32
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
import java.util.*;
public class dcc{
public static void main(String[] arge){
Scanner aa=new Scanner(System.in);
int xingqiji=0;
boolean lunnian;
int tianshu=0;
int zongtianshu=0;
System.out.print(\"请输入年\");
int nian=aa.nextInt();
System.out.print(\"请输入月\");
int yue=aa.nextInt();
if(nian%4==0&&nian%100!=0||nian%400==0){
lunnian=true;
}else {
lunnian=false;
}
for(int year=1900;year<nian;year++){
if(year%4==0&&year%100!=0||year%400==0){
zongtianshu+=366;
}else{
zongtianshu+=365;
}
}
for(int i=1;i<yue;i++){
if(i==1||i==3||i==5||i==7||i==9||i==11){
zongtianshu+=31;
tianshu=31;
}else if(i==4||i==6||i==8||i==10||i==12){
zongtianshu+=30;
tianshu=30;
}else if(i==2&&lunnian==true){
zongtianshu+=29;
tianshu=29;
}else if(i==2&&lunnian==false){
zongtianshu+=28;
tianshu=28;
}
}
if(yue==1||yue==3||yue==5||yue==7||yue==9||yue==11){
tianshu=31;
}else if(yue==4||yue==6||yue==8||yue==10||yue==12){
tianshu=30;
}else if(yue==2&&lunnian==true){
tianshu=29;
}else if(yue==2&&lunnian==false){
tianshu=28;
}
xingqiji=1+zongtianshu%7;
System.out.print(\"星期日\\t\");
for(int i=1;i<7;i++){
System.out.print(\"星期\"+i+\"\\t\");
}
System.out.print(\"\\n\");
for(int i=0;i<xingqiji;i++){
System.out.print(\"\\t\");
}
for(int i=1;i<=tianshu;i++){
if((xingqiji+i)%7==0){
System.out.print(i+\"\\n\");
}else{
System.out.print(i+\"\\t\");
}
}
}
}
|
|
|
|
|
|
|
TA的每日心情 | 奋斗 2012-12-6 10:20 |
---|
签到天数: 1 天 [LV.1]初来乍到
|
看了ls的评价
瞅了一下代码
果然
没风格  |
|
|
|
|
|
|
|
楼主貌似没闹明白8月份有几天,所以8月份之后的每月天数全部搞错;“闰年”的拼音应该是“runnian”不是“lunnian”...
楼主并没有重视程序风格和良好编码习惯的培养。建议楼主:1.找一本通用的关于程序设计风格的书;2.在google搜索“java style”学习下...
此贴由 太极 在 2008-07-25 22:27:10 最后编辑 |
|
|
|
|
|
|
TA的每日心情 | 奋斗 2012-12-6 10:20 |
---|
签到天数: 1 天 [LV.1]初来乍到
|
|
|
|
|
|
|