0
我在努力尋找一種方法來輸出這個數組/循環,以便只有10個輸出出現在一條線上。50的輸出 - 每條線最多可分成10個數字
public static void main(String[] args) {
double [] alpha = new double[50];
int num=1;
for (int i=0; i < alpha.length; i++) {
alpha[i] = num; //populate index 0-50 w/ 1-50
num++;
if (alpha[i] < 26) // first 25, print ^2
System.out.print(Math.pow(alpha[i],2)+ " ");
else // last 25, print value(3)
System.out.print(alpha[i]*3 + " ");
}
System.exit(0);
}
一個老把戲,但一個好。 +1。 – markspace 2015-02-08 22:46:19