0
public static void main(String[] args) {

    String input = args[0]; 

    String [] part = input.split(" "); 
    //splits string into 2 parts (action and characters to encode)
    String action = part[0];
    // action is what is done to letter i.e. decrypt or encrypt
    String plainText = part[0];
    char [] letters = plainText.toCharArray();
    //letters is the input of what to act on

        int n = plainText.length();
        //number of letters typed
        int boxsize; // overall size of box  
        boxsize = (int) Math.pow((Math.sqrt(n))+1,2);
        int Row = (int) Math.sqrt(boxsize); 
        int Col = Row;
        //length of rows AND columns since its square

    if (action.equals("-encrypt")) {

        char [][] box = new char[Row][Col];

        for (int i=0; i<Row; i++) {
        for ( int j=0; j<Col; j++) {

            System.out.println( i );

如果参数作为字符串给出,你如何填充二维字符数组?还有你如何打印框(数组),以便它从左到右垂直向下读取每一列?\ 例如命令行将是“-encrypt abcd”(不包括引号)我想要的输出是“acbd”

4

1 回答 1

0
String plainText = part[1];

被复制为 0

但通常没有引号 args[0] 将是动作,其余的 args[>=1] 间隔纯文本。

于 2013-04-11T06:59:45.693 回答