新手求教~一个C++的习题~~十万火急
最近小弟要做一个C++的作业由于是新手~显得一筹莫展~在此向各位高手求教~~ 首先这个作业是要做一个关于"最适合的直线"~譬如说在MICROSOFT EXCEL输入N组数据(x,y)去画一个直线图~~然后添加趋势线~~电脑就会自动添加一个最适合这些数据的直线,这条直线的格式是 y=mx+c~ 重点是输入N组数据(x,y)~然后电脑要计算出最适合这些数据的直线的m值和c值~还有误差~m是斜度~c是直线与Y轴的交点. 相关计算公式:注σ表示误差 http://storage.msn.com/x1pAdjo0uCo2H3c5ZkoGryTwxNkwijs04oJJ0sC61aknThXFgJa4g6FAFMGu-ODGlHHSJHvO-pn6mFd96PT0JrZzadfjUxqm67x92q4XIsyhqPfogbM8zDHyGfXjQDa0ggRUomCbbO3ro5D82c5pwWG_g 编程完成后具体内容入下: 1.ask the user to input N pairs of data values (xi,yi) 2.display the pairs of data clearly and concisely on the screen. 3.calculate and display the slope m and y-intecept c using the least squares fitting approach 4.calculate and display the uncertainty in the slope and y-intercept 5.Display a menu which will ask the user if they wish to (a) change a data pair (b) add any additional data, (c) input a totally new data set or (d) exit the program. If the user opts to change a data point the program will have to prompt the user asking which data point they would like to change and the new values to be inputted. The program should then redisplay the data with new slope, y-intercept and uncertainties etc as before. If the user opts to add additional data then once again the program should then redisplay the data with new slope, y-intercept and uncertainties etc as before. Remember, in this case N will have been increased. (General Hint: You should use suitable arrays to store your data) 中文译本:(PS.我学C++是用英文,所以中文翻译得可能有些含糊) 1.电脑叫使用者输入N组数据(x,y) 2.在屏幕上显示这N组数据. 3.计算和显示斜度m和c值 4.计算和显示,斜度m跟c值的误差. 5.显示一组菜单将会给用户选择:(a)改变一组数据, (b)增加任何数据,(c)重新输入新的数据,(d)离开程序. 如果选(a)程序会提示用户问哪组数据要改,改成什么值?之后程序会重新显示新的斜度m,c值和误差值. 如果选(b)电脑提示输入一组或多组数据~之后也要显示新的斜度m,c值和误差值.记住在这里N的值会增加 我们学校要我们自学~~然后就做这个题实在是过分啊~十万火急!!!希望各位高手给予援助小弟感激不尽.我的qq:544192764, MSN:junfeitse@hotmail.com |
[此贴子已经被作者于2005-11-25 2:49:27编辑过]