IM嗨這裏新和相當新的Java在學校香港專業教育學院有一個程序在這裏,Ive得到工作了剛纔打印它應該她的節目的方式如何打印出一列VS一排
import java.util.*;
public class stars
{
public static void main(String args[]){
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the starting Value");
for(int star=keyboard.nextInt(); star>=1; star--)
{ for(int starTwo=star;starTwo>=1; starTwo--)
{
System.out.println("*");
}
}
}
}
它現在打印在一個直列中,它有正確的數字「*」,只是格式錯誤。 我需要它所以第7行有7,第6行有6行5有5等。一路爲1.
預先感謝您。
向我們展示你的輸入,預期的結果,預計輸出 –
請理解的System.out.println意味着打印到一個新行。 您需要使用System.out.print(「*」); – Acewin