forked from nobodxbodon/java_in_hours_chn
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc5c598
commit c4d8b15
Showing
3 changed files
with
53 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class 识字循环类 { | ||
public static void main (String[] 参数) { | ||
int 识字量 = 1; | ||
int 每年翻倍数 = 2; | ||
int 年限 = 10; | ||
int 年份 = 0; | ||
|
||
while (年份 < 年限) { | ||
if (识字量 > 3000) { | ||
break; | ||
} | ||
识字量 = (1 + 每年翻倍数) * 识字量; | ||
年份 = 年份 + 1; | ||
} | ||
System.out.println(年份 + "年后认识" + 识字量 + "个字"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class 识字类 { | ||
public static void main (String[] 参数) { | ||
int 识字量 = 1; | ||
int 每年翻倍数 = 2; | ||
|
||
// 第一年 | ||
识字量 = (1 + 每年翻倍数) * 识字量; | ||
|
||
// 第二年 | ||
识字量 = (1 + 每年翻倍数) * 识字量; | ||
|
||
// 第三年 | ||
识字量 = (1 + 每年翻倍数) * 识字量; | ||
System.out.println("三年后认识" + 识字量 + "个字咯"); | ||
} | ||
} |