|
|
@ -164,4 +164,48 @@
|
|
|
|
| 101 | 小米 | 80 |
|
|
|
|
| 101 | 小米 | 80 |
|
|
|
|
-------------------------------------------------------
|
|
|
|
-------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### C10: 从文件中读取学生信息及成绩
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
选择菜单命令 `1`,提示输入文件名,若文件存在,则打开文件读取 CSV 格式保存的所有库存记录;否则,若文件不存在,则给出错误信息并结束。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
假设文件 `a.csv` 中,以 CSV (Comma-Separated Values)格式保存了如下记录:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
103,小红,80
|
|
|
|
|
|
|
|
104,小光,100
|
|
|
|
|
|
|
|
101,小米,80
|
|
|
|
|
|
|
|
102,小明,70
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
则读取记录的过程如下:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
请选择:1
|
|
|
|
|
|
|
|
读取数据
|
|
|
|
|
|
|
|
请输入文件名:a.csv
|
|
|
|
|
|
|
|
读取 4 记录
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 读取 | 2 保存 | 3 打印 | 4 查询 | 5 添加
|
|
|
|
|
|
|
|
6 修改 | 7 删除 | 8 排序 | 9 图表 | 0 退出
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
请选择:3
|
|
|
|
|
|
|
|
-------------------------------------------------------
|
|
|
|
|
|
|
|
| NUMBER | NAME | ON HAND |
|
|
|
|
|
|
|
|
-------------------------------------------------------
|
|
|
|
|
|
|
|
| 103 | 小红 | 80 |
|
|
|
|
|
|
|
|
| 104 | 小光 | 100 |
|
|
|
|
|
|
|
|
| 101 | 小米 | 80 |
|
|
|
|
|
|
|
|
| 102 | 小明 | 70 |
|
|
|
|
|
|
|
|
-------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 读取 | 2 保存 | 3 打印 | 4 查询 | 5 添加
|
|
|
|
|
|
|
|
6 修改 | 7 删除 | 8 排序 | 9 图表 | 0 退出
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
请选择:1
|
|
|
|
|
|
|
|
读取数据
|
|
|
|
|
|
|
|
请输入文件名:a
|
|
|
|
|
|
|
|
a: No such file or directory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|