2022年C语言文件 .pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《2022年C语言文件 .pdf》由会员分享,可在线阅读,更多相关《2022年C语言文件 .pdf(5页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、42C10. 已知数据文件 中存放有 1100之间各自然数n 的平方根, (文件中每行只存储一个数值数据) 。编程查找当n=7时其平方根(7 的平方根等于2.6458)在文件 中的位置(即记录号) ,并向文件t2.dat 输出该记录号。#include stdio.h #include stdlib.h #include math.h void main() FILE *fp,*fp1; double num; int i=0; if(fp=(fopen(d:12345678dat2.dat,rb+)=NULL) printf(cannot open the file!n); exit(0);
2、 if(fp1=(fopen(d:12345678t2.dat,wb+)=NULL) printf(cannot open the file!n); exit(0); while(feof(fp)=0) fscanf(fp,%6lfn,&num); i+; if(num=2.6458) fprintf(fp1,the number is:%d,i); printf(the num is:%d,i); break; fclose(fp); fclose(fp1); /the number is:8834C2. 已知在正文文件da1.dat中,每个纪录只有两项数据,第一项为一整数表示学生的学号,
3、第二项为形如xx.x 的一个实数, 试统计计算并向文件t2.dat 输出全部学生的平均成绩V 与 90 分以上 (含 90 分)的学生人数N 。#include stdio.h #include stdlib.h struct stu int num; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 5 页 - - - - - - - - - float score; stud; void main() FILE *fp,*fp1; int N=0,n=0; float
4、sum=0,V=0; if(fp=fopen(D:12345678da1.dat,rb+)=NULL) printf(cannot open the file!n); exit(0); if(fp1=fopen(D:12345678t2.dat,wb+)=NULL) printf(cannot open the file!n); exit(0); while(feof(fp)=0) fscanf(fp,%4d %5fn,&stud.num,&stud.score); printf(%4d %5.1fn,stud.num,stud.score); sum+=stud.score; n+; if(
5、stud.score=90) N+; V=sum/n; fprintf(fp1,average=%5.1f,90=%d,V,N); fclose(fp); fclose(fp1); /average= 65.5,90=7235C3. 已知在正文文件ch1.dat中, 每个记录的数据是有一个由字母组成的字符个数不多于 10 个的字符串,如:absolute。试查找文件中从第150 个记录到第250 个记录间出现的第一个最大的字符串,并向文件t2.dat 输出查找结果和该字符串中的字符个数n。36C4. 已知在正文文件ch1.dat 中,每个记录的数据是有一个由字母组成的字符个数不多于 10 个的
6、字符串,如:absolute。统计在该文件中只有4 个字符的字符串的个数n1 和字符串的最后一个字符是f 的字符串的个数n2,并将统计结果存入文件t2.dat 中。/ n1=54,n2=1738C6. 已知在正文文件da1.dat中,每个纪录只有两项数据,第一项为一整数表示学生的学名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 5 页 - - - - - - - - - 号,第二项为形如xx.x 的一个实数,试统计计算并向文件t2.dat 输出成绩排序在前20 名的学生的
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年C语言文件 2022 语言 文件
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内