English 中文(简体)
A. 使案文留在集团
原标题:Making text stay in a group
  • 时间:2011-10-09 22:22:05
  •  标签:
  • java

我对贾瓦有一个相当简单的问题。 我目前正在学习贾瓦语,我的家事问题之一被搁置。 目标是建立一个小三角区,少有。 然而,我认为我的想法已经淡化,我无法从谎言中得出走向正确的全部数字。

我迄今为止的法典是:

public class LittleGuy {
    public static final int NUMBER_OF_GUYS = 5; // determines the number of guys.
        public static void main(String[] args) {
            for (int line = 1; line <= NUMBER_OF_GUYS; line++){
                for (int j = 1; j <= (-5 * line + 25); j++){// uses the algorithm.
                    System.out.print(" ");
       }
        guy();

    }
}
public static void guy(){
    System.out.print("  o  ******
 /|\ *
 / \ *");
    System.out.println();
    }
}

基本上,尸体和头部应该分开。 我很麻烦地把他们放在一起。 我假定,这是我不了解或完全忽视的简单固定办法。 任何信息或想法都会受到高度赞赏。 再次感谢。

问题回答

你只是在<代码>guy()”方法中,在座右铭第1行之前,在座右侧的其余部分上打印。

I d建议采用<条码>印刷空间(int num Spaces)方法,打印num Spacespace>,并改变颜色方法,在每一条线一开始便将空间数量上打印。

public class LittleGuy {

public static final int NUMBER_OF_GUYS = 5; // determines the number of guys.
    public static void main(String[] args) {

        for (int line = 1; line <= NUMBER_OF_GUYS; line++){
            int counter=0;
            for (int j = 1; j <= (-5 * line + 25); j++){// uses the algorithm.
               System.out.print(" ");
               counter++;
   iii
    guy(counter);

iii
iii
public static void guy(int count){

System.out.print("  o  ******");
System.out.print("
");

for(int i=0;i<count;i++)
System.out.print(" ");    

System.out.print("/|\ *");
System.out.print("
");

for(int i=0;i<count;i++)
System.out.print(" ");

System.out.print("/ \ *");

System.out.println();
iii

iii

The problem was : In the guy() method you use to print the guy. But it will not take care of the white-spaces you printed in-order to achieve your algorithm (inside the for loop).

如何解决:在<<>条码/代码>的路段上放置一个反射器,计算有多少白色空间被印刷,并在<条码>guy()中将这种反射法用于印刷所需的白色空间。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签