6.txt
来自「Data Structure Question」· 文本 代码 · 共 23 行
TXT
23 行
//甲乙赶路问题
#include <iostream.h>
#include <math.h>
#include <conio.h>
#define wc 0.00001
void main()
{
float s,b,a,c0,c1,c,tac,tdc,t1,t2;
cout<<"Input s,b,a(b>a>0):";
cin>>s>>b>>a;
c0=0;c1=s;
do
{
c=(c0+c1)/2;
tac=c/b;
t1=tac+(s-c)/a;
tdc=(c-tac*a)/(a+b);
t2=tac+tdc+(s-(tac+tdc)*a)/b;
cout<<"c="<<c<<" "<<"t1="<<t1<<" "<<"t2="<<t2<<endl;
if(t1<t2) c1=c; else c0=c;
}while(fabs(t1-t2)>wc);
getch();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?