java - how do I flip this ruler up side down? -
this question exact duplicate of:
so i'm scratching head on how flip output ruler....upside down idea ? if run code you'll see output can't/don't how post sample here
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); (int = 1; <= inches; i++) { drawminorticks(line, ticks - 1); drawsinglemajortick(line, ticks, i); } } private static void drawruler(int inches, int ticks) { (int = 1; <= ticks + 1; ++i) { drawmajorticks(inches, i, ticks); system.out.println(); } } public static void main(string[] args) { drawruler(5, 5); }
}
just iterate backwards in drawruler()!
for (int = ticks + 1; > 0; --i) {
Comments
Post a Comment