如果UD = U,杜= d,UU = d,DD = U映射字符串他人在Java中
如果我得到的輸出 「UU杜UD」 有沒有辦法讓輸出這樣
uu du ud ---Output already got
d d u ---Because uu=d du=d ud=u
u u ---Because dd=u and the other u comes down
d ---finally uu=d so the output is d.
我得到這種類型的輸出有問題,因爲我不知道java很多。 我寫的代碼是
public class Test
{
public static void main(String[] args)
{
int count = 0;
int index = 0;
Scanner scan = new Scanner(System.in);
System.out.print("How many Line Paremeters?");
int amount = scan.nextInt();
// One array to hold all the names
String[] name = new String[amount];
System.out.print("You entered "
+ amount + " as the size of your name list.");
System.out.println(" ");
// Ask for all the names
for (index = 0; index < amount; index++)
{
System.out.print("Enter Line Paremeters: ");
name[index] = scan.next();
}
System.out.println(" ");
System.out.println("The order: ");
System.out.println(" ");
System.out.println();
for (String names1 : name)
{
System.out.print(names1 + " ");
}
}
}
這功課嗎? –
標題,描述和代碼是否有任何關係? – GriffeyDog
稍微的上下文可能會有所幫助...... –