资源简介
InvestigationofCar-speed.rar
![](http://www.nz998.com/pic/59790.jpg)
代码片段和文件信息
/*************************************************************************
*@ property in copyright :Guo Youtian
*@ author :Guo Youtian
*@ contact information :QQ:272318713 WeChat:Guoyoutiande
*@ result : calculate all the result of experiment two
*@ matters need ateention : do not change the content if possible
*@ the last change time :2017-05-10
**************************************************************************/
#include
#define N 7000 // 给数组开辟空间
#define L 300 // 给数组开辟空间
// 定义整形变量
int j h;
// 定义浮点型变量
float temp;
// a[N]用于存原始数据 sum[N]用于存所需中间量
float a[N] sum[N];
// 频率 累计频率
double frequency[L] accumulated_freq[L];
// 函数声明
void readdata();
void calculate();
int save_data();
void main()
{
readdata(); // 读取文本文件里的数据
calculate(); // 计算
save_data(); // 存文档
}
// 读取文本文件里的数据
void readdata()
{
int i = 0;
FILE *f; // 定义指针
// 打开并读取文件,f指向文件里第一个数据的地址
if((f = fopen(“quantity_of_speed.txt“ “r“)) == NULL)
{ // 增强程序的健壮性
printf(“无法打开\n“);
return;
}
// 将文件里的数据逐个读取到数组当中
while(!feof(f))
{
fscanf(f “%f“ &a[i]);
i++;
}
// 关闭文件
fclose(f);
// 四舍五入
for (i=0; i<6885; i++)
{
temp = a[i] - (int)a[i];
if (temp >= 0.5)
a[i] = (int)a[i] + 1;
else
a[i] = (int)a[i];
}
}
// 计算
void calculate()
{
int k=0;
// 频数,第一个for循环的范围由Excel表格排序给出循环区间
for (j=11; j<224; j++)
{
// 清零
sum[0] = 0;
// frequency[j] = 0;
// accumulated_freq[j] = 0;
for (k=0; k<6885; k++)
{
if (j == a[k])
frequency[j] += 1;
}
frequency[j] = frequency[j]/6885*100;
accumulated_freq[j] = accumulated_freq[j-1] + frequency[j];
}
}
// 存文档
int save_data()
{
FILE *pf=NULL;
pf=fopen(“data.txt“ “w“ );//假设test.txt文件为空
if(!pf)
{
printf(“打开文件失败,程序退出!“);
exit(1);
}
// 频率
fprintf(pf“频率: \n“);
for (j=11; j<224; j++)
{
fprintf(pf“速度为%dKm/h: %3.8f\t“j frequency[j]);
if(((j-11)%6)==0)
fprintf(pf“\n“);
}
fprintf(pf“\n“);
// 累计频率
fprintf(pf“累计频率: \n“);
for (j=11; j<224; j++)
{
fprintf(pf“速度为%dKm/h: %3.8f\t“j accumulated_freq[j]);
if(((j-11)%6)==0)
fprintf(pf“\n“);
}
if(pf)//关闭文件
{
fclose( pf);
pf=NULL;
}
printf(“数据已写入data.txt文件!\n“);
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 11204 2017-05-10 22:30 Investigation of Car-speed\data.txt
文件 4874 2017-05-10 22:26 Investigation of Car-speed\data_1.txt
文件 41984 2017-05-10 22:30 Investigation of Car-speed\Debug\experiment2.bsc
文件 209028 2017-05-10 22:30 Investigation of Car-speed\Debug\experiment2.exe
文件 235688 2017-05-10 22:30 Investigation of Car-speed\Debug\experiment2.ilk
文件 9399 2017-05-10 22:30 Investigation of Car-speed\Debug\experiment2.obj
文件 175588 2017-05-10 17:27 Investigation of Car-speed\Debug\experiment2.pch
文件 500736 2017-05-10 22:30 Investigation of Car-speed\Debug\experiment2.pdb
文件 0 2017-05-10 22:30 Investigation of Car-speed\Debug\experiment2.sbr
文件 33792 2017-05-10 22:30 Investigation of Car-speed\Debug\vc60.idb
文件 53248 2017-05-10 22:30 Investigation of Car-speed\Debug\vc60.pdb
文件 2566 2017-05-10 22:30 Investigation of Car-speed\experiment2.c
文件 3463 2017-05-10 22:30 Investigation of Car-speed\experiment2.dsp
文件 530 2017-05-10 22:30 Investigation of Car-speed\experiment2.dsw
文件 33792 2017-05-10 22:30 Investigation of Car-speed\experiment2.ncb
文件 48640 2017-05-10 22:30 Investigation of Car-speed\experiment2.opt
文件 1977 2017-05-10 22:30 Investigation of Car-speed\experiment2.plg
文件 43070 2017-05-10 15:51 Investigation of Car-speed\quantity_of_speed.txt
目录 0 2018-12-01 12:25 Investigation of Car-speed\Debug
目录 0 2018-12-01 12:25 Investigation of Car-speed
----------- --------- ---------- ----- ----
1409579 20
相关资源
- 价值2k的H漫画小说系统
- Pythonamp;课堂amp;笔记(高淇amp;400;集第
- ddos压力测试工具99657
- UML建模大全
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- FTP课程设计(服务端+客户端)
- 计算机图形学 边填充算法实现代码
- 电力系统潮流计算程序集合
- oracle数据迁移项目实施方案
- Web Api 通过文件流 文件到本地
- Visio图标-最新最全的网络通信图标库
- Spire API文档
- OpenGL参考手册
- Python中Numpy库最新教程
- SPD博士V5.3.exe
- 直流无刷电机方波驱动 stm32 例程代码
- layui后台管理模板
- 仿知乎界面小程序源代码
- 云平台-阿里云详细介绍
- photoshop经典1000例
- scratch垃圾分类源码(最终版本).sb
- IAR ARM 7.8破解
- TI CCS V5.4 安装步骤及破解文件
- 松下plc FP-XH的驱动
- 局域网硬件信息收集工具
- 加快Windows XP操作系统开机速度
- 联想启天M4350 BIOS升级文件
- 操作系统教程课后答案华中科技大学
评论
共有 条评论