1 #include<iostream>//chengdacaizi 08.11.12 2 #include<iomanip> 3 #define p 3.1415927 4 using namespace std; 5 int main() 6 { 7 int num=1; 8 double getdistance(double , int ); 9 double getspeed(double , double ); 10 double diameter; 11 int revolutions; 12 double time; 13 double distance; 14 double speed; 15 while(1){ 16 cin>>diameter>>revolutions>>time; 17 if(revolutions==0) 18 break; 19 distance = getdistance(diameter,revolutions); 20 speed = getspeed(distance,time); 21 cout<<"Trip #"<<num<<": "<<setiosflags(ios::fixed)<<setprecision(2)<<distance<<" "<<speed<<endl; 22 num++; 23 } 24 return 0; 25 } 26 double getdistance(double diameter,int revolution) 27 { 28 diameter/=63360; 29 diameter*=p; 30 diameter*=revolution; 31 return diameter; 32 } 33 double getspeed(double distance, double time) 34 { 35 return distance/time*3600; 36 }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com