章节小结中等腰三角形;
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
System.out.print(“请输入等腰三角形的高:”);
int high=sc.nextInt();
System.out.println(“高为”+high+”的等腰三角形如下:”);
for(int y=1;y<=high;y++){
for(int x=1;x<=2*high-1;x++){
if((y>=-x+high+1)&&(y>=x-high+1))
System.out.print(y==1?’^’:’-‘);
else System.out.print(’ ‘);
}
System.out.println(“”);
}
}
}
文章标题
最新推荐文章于 2023-10-19 15:03:50 发布