- 10
- 0
- 约3.07千字
- 约 6页
- 2021-04-15 发布于山东
- 举报
精品文档
精品文档
PAGE
精品文档
第15次练习-夏7周
1.教材练习12-1(p243) 将短句Programmingisfun 写入某文件,文件名自定。
请在此插入源代码
includestdio.h
includestdlib.hintmain(void)
{
FILE*fp;if((fp=fopen(f1.txt,w))==NULL){
printf(Fileopenerror!\n);
exit(0);
}
fprintf(fp,%s,Programmingisfun);
if(fclose(fp)){
printf(Cannotclosethefile!\n);
exit(0);
}
return0;
}
2.教材练习12-2(p247)
已知一个数据文件
f.dat中保存了
5个学生的考试成绩,包括学号、
姓名和分数,文件内容如下:
301101
张文
91
301102
陈慧
85
301103
王卫东
76
301104
郑伟
69
301105
郭温涛
55
编程要求:
1)将文件的内容读出并显示到屏幕中
2)在上述基础上,输出成绩最低和成绩最高的学生的学号、姓名和成绩。
includestdio.h
includestdlib.h
includestring.hintmain(void)
{
FILE*fp;
1 浙江大学计算机学院
第15次练习-夏7周
原创力文档

文档评论(0)