android

时间:2015-05-19 16:15:00

标签: java android alertdialog

我试图在警报对话框中打印一组pascal三角形行,但它不打印在三角形上,它会打印每行的每个警告对话框。 有没有办法在一个三角形中打印它们?帮助谢谢:)

  public void onClick(View v) {
            String space = "";
            EditText id1 = (EditText) findViewById(R.id.id1);
            int num = Integer.parseInt(id1.getText().toString());
            print(num);

        }
        public void print(int n){
           String space="";
            int[] previousRow;
            int[] currentRow = {1};
            printArray(currentRow);
            previousRow = currentRow;
            for (int i = 2; i <= n;i++) {
                currentRow = new int[i];
                currentRow[0] = 1;
                currentRow[i - 1] = 1;
                for (int j = 0; j <= i - 3; j++) {
                    currentRow[j + 1] = previousRow[j] + previousRow[j + 1];
                }
                printArray(currentRow);


                previousRow = currentRow;
            }
        }



        public void printArray(int[] array) {

            String wow="";
            String space=" ";
            for (int i = 0; i < array.length; i++) {
              wow=array[i]+"" + ""+wow;


            }

            space="\n";
            AlertDialog(wow,space);



    }

    });

0 个答案:

没有答案