注意:你提交的應該是一個整數,不要填寫任何多餘的內容或說明性文字。css
/** * 生日蠟燭 * * 某君從某年開始每一年都舉辦一次生日party,而且每次都要吹熄與年齡相同根數的蠟燭。 如今算起來,他一共吹熄了236根蠟燭。 * 請問,他從多少歲開始過生日party的? * * @author Zhang */ public class srlz { public static void main(String[] args) { for (int year = 1; year < 120; year++) { // 從一歲開始 int num = year; for (int c = 1; c < 120; c++) { // 過了幾年 num += year + c; if (num == 236) { System.out.println(year + "---" + c + "---" + num);//26---7---236 } } } } }