【发布时间】:2020-01-19 22:57:22
【问题描述】:
我想做一个程序来产生这样的东西(下划线上下颠倒):output1
注意:我不想使用 UNICODE。
但相反,我的输出是这样的(下划线打印在底部):output2
public class Landscape {
String terrainString;
Landscape(){
terrainString = "";
}
public void flat(int lengthOfFlatPortion){
for (int count = 0; count < lengthOfFlatPortion; count++) {
terrainString += "_";
}
}
public void hill(int lengthOfHillTop){
terrainString += "/";
for (int count = 0; count < lengthOfHillTop; count++) {
terrainString += "_";
}
terrainString += "\\";
}
public void print(){
System.out.println(terrainString);
}
}
public class Main {
public static void main(String[] args){
Landscape landscape = new Landscape();
//BUILD Landscape Script
landscape.flat(3);
landscape.hill(4);
landscape.flat(6);
landscape.hill(1);
landscape.flat(1);
//END SCRIPT
landscape.print();
}
}
【问题讨论】:
-
使用
‾(unicode 203e) 代替_。