完成第二章的内容

This commit is contained in:
2023-03-04 15:52:20 +08:00
parent f2a40a910e
commit 1fe20bde9f
11 changed files with 994 additions and 337 deletions
+26 -27
View File
@@ -28,18 +28,17 @@ Java的布尔类型和C保持一致,基本的运算符也和C保持一致。
例如:0B 和 0A 代表两个byte,转换成位是:
| 字节1(0x08) | 字节2(0x07) | 说明 |
| ----------- | ----------- | ------------ |
| 0000-1000 | 0000-0111 | 对应的二进制 |
| 字节1(0x08) | 字节2(0x07) | 说明 |
| --------- | --------- | ------ |
| 0000-1000 | 0000-0111 | 对应的二进制 |
| 位操作 | 结果 | 说明 |
| ------------ | --------- | ------------------------------ |
| 位操作 | 结果 | 说明 |
| ------------ | --------- | --------------- |
| 0x0A & 0x0B | 0000-1000 | 按照每一位对应进行与运算的结果 |
| 0x0A \| 0x0B | 0000-1111 | 按照每一位对应进行或运算的结果 |
**位操作作为了解。**
### 1.4. 选择语句
@@ -54,7 +53,7 @@ Java的布尔类型和C保持一致,基本的运算符也和C保持一致。
这个方式在书上没有讲,在考试中可能会遇到这种情况。
```java {.line-numbers}
```java
import java.util.Scanner;
/**
@@ -64,20 +63,20 @@ import java.util.Scanner;
*
*/
public class LoopRead {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Please input a sequence of integer, divided by space.");
int sum = 0;
while (true) {
if (scanner.hasNextInt()) {
sum += scanner.nextInt();
} else {
break;
}
}
scanner.close();
System.out.println("The sum is: " + sum);
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Please input a sequence of integer, divided by space.");
int sum = 0;
while (true) {
if (scanner.hasNextInt()) {
sum += scanner.nextInt();
} else {
break;
}
}
scanner.close();
System.out.println("The sum is: " + sum);
}
}
```
@@ -93,9 +92,9 @@ public class LoopRead {
本章的内容中的大部分技术要点都与C保持一致,因此之需要掌握几个例子就可以了:
1. AdditionQuiz
2. SubtractionQuiz
3. ComputeAndInterpretBMI
4. ComputeTax
5. ChineseZodiac
6. 本页的补充例子,循环读取输入
1. AdditionQuiz
2. SubtractionQuiz
3. ComputeAndInterpretBMI
4. ComputeTax
5. ChineseZodiac
6. 本页的补充例子,循环读取输入