| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 460 人关注过本帖
标题:为什么编译没问题运行有问题??
只看楼主 加入收藏
w289592467
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2007-4-19
收藏
 问题点数:0 回复次数:3 
为什么编译没问题运行有问题??

import java.util.*;
class A{
private int b;
private int d;
A(){
b=1;
}
//输入年月时计算日历
void B(int year,int month){
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
d=31;
if(month==4||month==6||month==9||month==11)
d=30;
if(month==2){
if(year%400==0||year%100!=0&&year%4==0)
d=29;
else
d=28;
System.out.println(year+"年"+month+"月");
System.out.println("一 二 三 四 五 六 日");
for(int i=1;i<=d;i++)
{
System.out.print(i );
if(b+7<i)
{
b+=7;
System.out.println();
}
}
}
}//不输入数据计算该月的日历
void C(){
int month,year;
Calendar today;
today=Calendar.getInstance();
month=today.get(Calendar.MONTH);
year=today.get(Calendar.YEAR);
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
d=31;
if(month==4||month==6||month==9||month==11)
d=30;
if(month==2){
if(year%400==0||year%100!=0&&year%4==0)
d=29;
else
d=28;
System.out.println(year+"年"+month+"月");
System.out.println("一 二 三 四 五 六 日");
for(int j=1;j<=d;j++)
{
System.out.print(j );
if(b+7<j)
{
b+=7;
System.out.println();
}
}
}

}
}
public class Date1{
Date1(){}
public static void main(String[]args)
{
Scanner bb=new Scanner(System.in);
A rr=new A();
int a,b;
a=bb.nextInt();
b=bb.nextInt();
if(a>0)
{
rr.B(a,b);
}else{
rr.C();
}
}
}
搜索更多相关主题的帖子: 编译 运行 
2007-04-19 17:25
w289592467
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2007-4-19
收藏
得分:0 
帮帮我这新手好吗??
2007-04-19 18:09
w289592467
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2007-4-19
收藏
得分:0 

为什么在JBuilder能运行。。在DOS里不可以的??

2007-04-19 19:40
Eastsun
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:32
帖 子:802
专家分:0
注 册:2006-12-14
收藏
得分:0 
以下是引用w289592467在2007-4-19 17:25:22的发言:


import java.util.*;
class A{
private int b;
private int d;
A(){
b=1;
}
//输入年月时计算日历
void B(int year,int month){
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
d=31;
if(month==4||month==6||month==9||month==11)
d=30;
if(month==2){
if(year%400==0||year%100!=0&&year%4==0)
d=29;
else
d=28;
} //这里加个括号!!
System.out.println(year+\"年\"+month+\"月\");
System.out.println(\"一 二 三 四 五 六 日\");
for(int i=1;i<=d;i++)
{
System.out.print(i );
if(b+7<i)
{
b+=7;
System.out.println();
}
}
//} 把这个括号去掉!!
}//不输入数据计算该月的日历
void C(){
int month,year;
Calendar today;
today=Calendar.getInstance();
month=today.get(Calendar.MONTH);
year=today.get(Calendar.YEAR);
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
d=31;
if(month==4||month==6||month==9||month==11)
d=30;
if(month==2){
if(year%400==0||year%100!=0&&year%4==0)
d=29;
else
d=28;
}// 同理
System.out.println(year+\"年\"+month+\"月\");
System.out.println(\"一 二 三 四 五 六 日\");
for(int j=1;j<=d;j++)
{
System.out.print(j );
if(b+7<j)
{
b+=7;
System.out.println();
}
}
}

// }同理
}
public class Date1{
Date1(){}
public static void main(String[]args)
{
Scanner bb=new Scanner(System.in);
A rr=new A();
int a,b;
a=bb.nextInt();
b=bb.nextInt();
if(a>0)
{
rr.B(a,b);
}else{
rr.C();
}
}
}


My BlogClick Me
2007-04-19 20:59
快速回复:为什么编译没问题运行有问题??
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020746 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved