C++ Primer Plus 第六版课后习题答案(第三章)

本文分享了C++ Primer Plus第六版第三章的课后习题答案,为学习C++的读者提供参考。
摘要由CSDN通过智能技术生成

最近在读这本C++经典之经典,把一些课后习题作业发出来给大家参考:

#include <iostream>
using namespace std;
void p_1()
{
    int height;
    const int c = 12;
    cout << "Enter your height(in):"<<endl;
    cin >> height;
    int ft = height/c;
    int in = height%c;
    cout <<"Your height is "<< ft <<"ft "<< in <<"in."<<endl;
}

void p_2()
{
    int ft,in;
    float pounds;
    cout << "Enter your height in ft and in:"<<endl;
    cin >> ft;
    cin >> in;
    cout << "Enter your weight in pounds:"<<endl;
    cin >> pounds;
    float height = (12*ft+in)*0.0254;
    float kg = pounds/2.2;
    float BMI = kg/(height*height);
    cout << "Your BMI is "<<BMI<<endl; 
}

void p_3()
{
    int degrees,minutes,seconds;
    const double c = 60;
    cout <<
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值