gpt4 book ai didi

java - 在Java中没有unicode的情况下颠倒绘制下划线

转载 作者:行者123 更新时间:2023-12-02 01:07:31 24 4
gpt4 key购买 nike

我想生成一个如下所示的绘图(输出两行),其中绘图的顶部是一个颠倒的下划线:output

相反,它在同一行上输出所有内容。我也不想使用 UNICODE。

public class Landscape {

String terrainString1;
String terrainString2;

Landscape(){
terrainString1="";
terrainString2="";
}

public void flat(int lengthOfFlatPortion){
for (int count=0; count<lengthOfFlatPortion; count++){
terrainString1+=" ";
terrainString2+="_";
}
}
public void hill(int lengthOfHillTop){
terrainString1=" ";
terrainString2="/";
for (int count=0; count<lengthOfHillTop; count++){
terrainString1+="_";
terrainString2+=" ";
}
terrainString1+=" ";
terrainString2+="\\";
}

public void print(){
System.out.println(terrainString1);
System.out.println(terrainString2);
}

}

public class Main {
public static void main(String[] args){
Landscape landscape = new Landscape();

landscape.flat(3);
landscape.hill(5);
landscape.flat(2);
landscape.hill(3);
landscape.flat(4);
landscape.hill(0);
landscape.flat(2);

landscape.print();
}
}

最佳答案

我不知道这是否违反了您的“无 Unicode”要求,但 ASCII 238 处的“Macron”字符 ( ´ ) 可以使用,具体取决于所选的字体。

__/¯¯\__/¯\_     // This is a test of Macron character

否则,如果可以使用 Unicode,则会有一个特定的“上划线”字符 ( ‾ ) (U+203E)。

__/‾‾\__/‾\_     // This is a test of overline character

关于java - 在Java中没有unicode的情况下颠倒绘制下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59829281/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com