1
import java.io.*;
public class MgSq
{
    public static BufferedReader input = new BufferedReader(new 
public
InputStreamer(System.in));
    public static void main (String args[]) throws Exception
    {

      int w, x, y, z, b, key;
      boolean n_ok;
      int [] [] square = new int [15] [15];
      {
         System.out.print("Size of square? ");
         b = Integer.parseInt(input.readLine());
     n_ok = (z<=b) & (b<=15+1) & (b%2==1);
         if ( n_ok )
      {
               for (w=0;w<b;w++)
               for (x=0;x<b;x++) square[w][x] = 0;
               square[0][(int)(b-1)/2] = 1;
               key = 2;
               w = 0;
               x = (int)(b-1)/2;
               while ( key <= b*b )
           {
           y = w - 1;
           if ( y < 0 ) y = y + b;
               z = x - 1;
           if ( z < 0 ) z = z + b;
               if ( square[y][z] != 0 ) w = (w+1) % b;
               else 
           { 
        w = y; x = z;
           }
               square[w][x] = key;
               key = key + 1;
           }
         System.out.println("Magic square of size " + b);
         for (w=0;w<b;w++)
            {
               for (x=0;x<b;x++)
                  System.out.print("\t"+square[w][x]);
               System.out.println();
            }
         }      

    }
         System.out.println("Error in number, try again.");
}
}

次のエラーが発生し続けます。

MgSq.java:4 error: cannot find symbol 
public static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

symbol: class InputStreamer
class: MgSq
4

5 に答える 5

3

をインポートするだけなのでjava.io.*InputStreamerおそらくタイプミスであり、代わりに使用したいと考えていますInputStream

于 2013-03-18T14:21:01.317 に答える
1

That second public in the following line doesn't make sense:

public static BufferedReader input = new BufferedReader(new 
public 
InputStreamer(System.in));

change it to

public static BufferedReader input = new BufferedReader(new InputStreamer(System.in));

and apparently InputStreamer isn't actually a class. as other people said, try InputStreamReader or InputStream

于 2013-03-18T14:20:19.923 に答える
1

public前から削除しnew InputStreamReaderます。

于 2013-03-18T14:20:33.920 に答える
1

InputStreamerに変更InputStreamReader

于 2013-03-18T14:21:27.063 に答える
1
public static BufferedReader input = new BufferedReader(new 
public
InputStreamer(System.in));

する必要があります

public static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
于 2013-03-18T14:23:29.993 に答える