⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intcount.java

📁 java编程思想第四版习题答案
💻 JAVA
字号:
// control/IntCount.java
// TIJ4 Chapter Control, Exercise 7, page 146
// Modify exercise 1 so that the program exits by using the break keyword at
// value 99. Try using return instead.

import static net.mindview.util.Print.*;

public class IntCount {
	static void Count1(int n) {
		for(int i = 0; i < n; i++)
			print(i + 1);

	}
	static void Count2(int n) {
		for(int i = 0; i < n; i++) {
			print(i + 1);
			if(i == 99)
				break;
		}
	}
	static void Count3(int n) {
		for(int i = 0; i < n; i++) {
			print(i + 1);
			if(i == 99)
				return;
		}
	}
	public static void main(String[] args) {
		Count1(100);
		Count2(100);
		Count3(100);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -