c++ prime plus 第三章编程题答案

    技术2024-11-06  11

    #include<iostream> #include<cstdlib> using namespace std; const float change = 0.0833333; void output(int); int main(){ int height; cout<<"Please input your height:___\b\b\b"; cin>>height; output(height); system("pause"); return 0; } void output(int height){ cout<<"Your height is "<<height*change<<" foots"<<endl; }

    #include<iostream> #include<cstdlib> using namespace std; const double foots = 12; const double pounds = 2.2; const double memters = 0.0254; void change(double,double,double); int main(){ double chi,cun,bang; cout<<"Please input your height:"; cin>>chi>>cun; cout<<"Please input your weight:"; cin>>bang; change(chi,cun,bang); system("pause"); return 0; } void change(double chi,double cun,double bang){ double yingcun = foots*chi + cun; double m = memters * yingcun; double kg = pounds * bang; double bmi; bmi = kg/(m*m); cout<<"Your BMI is "<<bmi<<"."<<endl; }

    #include<iostream> #include<cstdlib> using namespace std; const long day = 24; const long hour = 60; const long minute = 60; void change(int second){ int tian,xiaoshi,fenzhong,miao; tian = second/(day*hour*minute); xiaoshi = (second - (tian*day*hour*minute))/(hour*minute); fenzhong = (second - (tian*day*hour*minute) - (xiaoshi*hour*minute))/hour; miao = (second - (tian*day*hour*minute) - (xiaoshi*hour*minute) - (fenzhong*minute)); cout<<second<<" seconds = "<<tian<<" days and "<<xiaoshi<<" hours and "<<fenzhong<<" minutes and "<<miao<<" seconds."<<endl; } int main(){ long second; cout<<"Enter the seconds:"; cin>>second; change(second); system("pause"); return 0; }

    #include<iostream> #include<cstdlib> using namespace std; int main(){ long double world; long double china; cout<<"Enter the population of world: "; cin>>world; cout<<"Enter the population of china: "; cin>>china; double a; a = (china/world)*100; cout<<"The population of china is "<<a<<"% of the world population"<<endl; system("pause"); return 0; }
    Processed: 0.032, SQL: 9