0
所以我抓我的頭如何翻轉輸出這是一個統治者....顛倒任何想法?如果您運行的代碼,你會看到的輸出,我不能/不會怎麼在這裏發表一個樣本我該如何翻轉這把尺子?
public class Ruler {
private static void drawMinorTicks(int line, int ticks) {
if (ticks > 1) {
drawMinorTicks(line, ticks - 1);
}
if (line <= ticks) {
System.out.print('|');
} else {
System.out.print(' ');
}
if (ticks > 1) {
drawMinorTicks(line, ticks - 1);
}
}
private static void drawSingleMajorTick(int line, int ticks, int label) {
if (line <= ticks) {
System.out.print('|');
} else {
System.out.print(label);
}
}
private static void drawMajorTicks(int inches, int line, int ticks) {
drawSingleMajorTick(line, ticks, 0);
for (int i = 1; i <= inches; i++) {
drawMinorTicks(line, ticks - 1);
drawSingleMajorTick(line, ticks, i);
}
}
private static void drawRuler(int inches, int ticks) {
for (int i = 1; i <= ticks + 1; ++i) {
drawMajorTicks(inches, i, ticks);
System.out.println();
}
}
public static void main(String[] args) {
drawRuler(5, 5);
}
}
你肯定很[敏銳](http://stackoverflow.com/questions/25942592/im-trying-to-print-this-ruler-horizontally-in-java)在[統治者]( http://stackoverflow.com/questions/25954584/how-to-print-this-horizontally),不是嗎? – 2014-09-22 21:07:28
不要多次提問同一個問題。 – 2014-09-22 21:51:13