| Profilo di AlexAlexFotoBlogElenchi | Guida |
|
19 novembre try to solve acsc using cpp做到作业最后一题结果得出个一元6次方程, 计算器没法计, 没法, 只能编程取近似值算了.
到目前为止还未是不是自己计错数.
//solve the acsc problem's question for the equation:
// // 0=-120-5(1-1/((1+i)(1+i)(1+i)(1+i)(1+i)))/i+50(1-1/((1+i)(1+i)(1+i)(1+i)))/i(1+i) // //Take the nearest result, so set 0.00000000000001 almost equal to 0 // #include <iostream> #include <cstdlib> #include <cmath> using namespace std;
const float min=0.00000000000001;
int main()
{ float i,tempResult,absVal; for (i=0.1;i<0.12;i=i+0.0000001) { tempResult=-120-5*(1-pow((1+i),-5))/i+50*(1-pow((1+i),-4))/(i*(1+i)); if (tempResult==0) { cout<<"The yield rate is: "<< i <<endl; return 0; } else { absVal=abs(tempResult); if (absVal<=min) cout<<"The yield rate is: "<< i <<endl; } } return 1; } Script started on Sat Nov 19 20:56:54 2005
news: EMACS FTP CSSS Script on hercules[1]% acsc The yield rate is: 0.113387
Script on hercules[2]% exit exit
script done on Sat Nov 19 20:57:06 2005 Commenti (2)Per aggiungere un commento, accedi con il tuo Windows Live ID (se utilizzi Hotmail, Messenger o Xbox LIVE possiedi già un Windows Live ID). Accedi Non hai ancora un Windows Live ID? Registrati
RiferimentiL'URL di riferimento per questo intervento è: http://reginaalex.spaces.live.com/blog/cns!4E38DBC3E5B6207D!241.trak Blog che fanno riferimento a questo intervento
|
|
|