你的程序整体编的应该没有什么问题
但是我觉得你应该将m,n,t的之进行一下初始化

int m=0;
int n=0;
int t=0;
我编译了一下
这样就可以了

解决方案 »

  1.   

    int x,y,z;
          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);
              }
            }
          }
      

  2.   

    下面是错误提示:
    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
      

  3.   

    java对变量初始化比较严格,习惯就好了!我也试了,没问题:
    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);
      }
    }
      

  4.   

    public class ji{
     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;}
         }
       }
      }
     }
    }
      

  5.   

    if (z == (300 - 15 * x - 9 * y) & z == (100 - x - y)) 这句有点问题!
      

  6.   

    这这句if((n*5+m*3+x/3)==100&x==(100-n-m))有点问题!
    应改为:if (z == (300 - 15 * x - 9 * y) & z == (100 - x - y))