你的程序整体编的应该没有什么问题
但是我觉得你应该将m,n,t的之进行一下初始化
即
int m=0;
int n=0;
int t=0;
我编译了一下
这样就可以了
但是我觉得你应该将m,n,t的之进行一下初始化
即
int m=0;
int n=0;
int t=0;
我编译了一下
这样就可以了
解决方案 »
- 在线求助,关于java反编译。
- SWT中向Text追加信息?
- JAVA 读文件的一个问题
- 关于java.awt.Choice的弹出菜单的高度。
- 这样的错误是什么问题??description The server encountered an internal error () that prevented it from fulfilling this request....
- 操作数据库很慢,大概会是什么原因
- 如何用代码实现内建SMTP主机?
- 请问局域网内机器如何与外部实ip建立socket连接?
- 谁有ApacheModuleJServ.dll这个文件发到我的邮箱啊
- 快来快来着火了
- j2sdk的帮助在哪里?
- 怎么区别button?
int g=0;
for(x=1;x<20;x++){
for(y=1;y<(100-5*x);y++){
z=100-x;
z=z-y; int tmp=0;
tmp=15*x+9*y;
tmp=tmp+z;
if(tmp==300){
g++;
System.out.println("第"+g+"组: ");
System.out.print("muji: " + x + " ");
System.out.print("gongji: " + y + " ");
System.out.println("xiaoji: " + z);
}
}
}
ji.java:14: variable m might not have been initialized
System.out.println("muji= "+m);
^
ji.java:15: variable n might not have been initialized
System.out.println("gongji= "+n);
^
ji.java:16: variable t might not have been initialized
System.out.println("xiaoji= "+t);
^
3 errors
public class test {
public static void main(String args[]) {
int x, y, z;
int m = 0;
int n = 0;
int t = 0;
for (x = 1; x < 20; x++) {
for (y = 1; y < 33; y++) {
for (z = 1; z < 300; z++) {
if (z == (300 - 15 * x - 9 * y) & z == (100 - x - y)) {
m = x;
n = y;
t = z;
break;
}
} }
}
System.out.println("muji= " + m);
System.out.println("gongji= " + n);
System.out.println("xiaoji= " + t);
}
}
public static void main(String[] args){
for(int n=0;n<=20;n++){
for(int m=0;m<=33;m++){
for(int x=0;x<=100;x++){
if((n*5+m*3+x/3)==100&x==(100-n-m))
{ System.out.println("n="+n);
System.out.println("m="+m);
System.out.println("x="+x);
break;}
}
}
}
}
}
应改为:if (z == (300 - 15 * x - 9 * y) & z == (100 - x - y))