/* 此程序针对上海交通大学 气垫导轨上碰撞瞬间的测量 实验编写.
* 这是我写的一个新版本,与上一个版本相比,这个只要把数据文件拖曳到编译好的软件上就可以了。
* This program is compiled by G++ in Linux.
* This program is written by 张浩.
* The result will be output into the txt file "result.txt".
* StudentID: 5050309640
* ClassID: F0503023
* Date: 2007-11-12
*/
#include
#include
#include
using namespace std;
int main(int argc, char* argv[])
{
ofstream out("result.txt");
ifstream in(argv[1]);
string strtemp="";
for(int i=0;i<8;i++)
in>>strtemp;
long sum=0, low=1000;
double result=0;
int temp=0;
while(in>>temp)
{
sum+=temp;
low=low>temp?temp:low;
}
result=double(1000*(sum-low*1000)/256)/1000000;
//------------------------------------------------------
double quality, length=0.0100, t1, t2, result1,error;
cout<<"请输入滑块质量,单位Kg:"< cin>>quality;
cout<<"请输入两次通过的时间间隔t1&t2,单位ms,用空格隔开:"< cin>>t1>>t2;
result1=quality*length*(1000/t1+1000/t2);
error=100*(result-result1)/result;
out<<"**********************************************"< out< out< out< cout<<"The result has been output into the result.txt"< return 0;
}
阅读(1288) | 评论(0) | 转发(0) |