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

在这里插入图片描述

#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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值