《C语言程序设计教程》实验报告范本.doc
《《C语言程序设计教程》实验报告范本.doc》由会员分享,可在线阅读,更多相关《《C语言程序设计教程》实验报告范本.doc(6页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、第15次练习-夏7周1 教材练习12-1(p243) 将短句Programming is fun 写入某文件,文件名自定。请在此插入源代码# include # include int main(void)FILE *fp;if(fp=fopen(f1.txt,w)=NULL)printf(File open error!n);exit(0);fprintf(fp,%s,Programming is fun);if(fclose(fp)printf(Can not close the file!n);exit(0);return 0;2 教材练习12-2 (p247) 已知一个数据文件f.da
2、t中保存了5个学生的考试成绩,包括学号、姓名和分数,文件内容如下:301101 张文 91301102 陈慧 85301103 王卫东76301104 郑伟 69301105 郭温涛55编程要求:1)将文件的内容读出并显示到屏幕中2)在上述基础上,输出成绩最低和成绩最高的学生的学号、姓名和成绩。# include # include # include int main(void)FILE *fp;int num, maxnum,minnum;char stname10,maxname10,minname10;int score, maxscore = 0, minscore = 100;if
3、(fp=fopen(f.dat,r)=NULL)printf(File open error!n);exit(0);while(! feof(fp)fscanf(fp,%d%s%d,&num,stname, &score);printf(%d%8s%4dn,num,stname,score);if(score=maxscore)maxnum=num;strcpy(maxname,stname);maxscore=score;if(score=minscore)minnum=num;strcpy(minname,stname);minscore=score;printf(成绩最高: %d%8s%
4、4dn,maxnum,maxname,maxscore);printf(成绩最低: %d%8s%4dn,minnum,minname,minscore);if(fclose(fp)printf(Can not close the file!n);exit(0);return 0;3教材练习12-3(p254): 读一个指定的文本文件,显示在屏幕上,如果有大写字母,则改成小写字母再输出,并统计行数。根据回车符统计文件行数。要处理的文件名通过键盘读入字符串指定。测试数据要求至少读入3行包含大写字母和其它字母混合的字符串# include # include int main(void)FILE *
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C语言程序设计教程 语言程序设计 教程 实验 报告 范本
限制150内