1.使用一个整数输入自己的身高(单位为cm),并将此身高转化为米和厘米共同表示的形式,使用下划线字符来指示输入的位置,使用一个const符号常量来表示转换因子。

#include<iostream>
using namespace std;
const int transform = ;
int main()
{
cout << "请输入自己的身高,单位为厘米:___\b\b\b" ;//使用下划线字符来指示输入的位置
int height;
cin >> height;
cin.get();
cout << "你的身高是: " << height << "公分" << endl;
int meter;
meter = height / transform;
int cm;
cm = height % transform;
cout << height << "公分是" << meter << "米加" << cm << "厘米" << endl;
cin.get();
return ;
}

运行结果:  

  请输入自己的身高,单位为厘米:190
  你的身高是: 190公分
  190公分是1米加90厘米

2.要求以几英尺几英寸的方式输入身高,并以磅为单位输入其体重,计算IBM指数。

#include<iostream>
using namespace std;
const double Inch2Meter = 0.254;
const double Kilo2Pound = 2.2;
const int Foot2Inch = ; int main()
{
double height_foot = 0.0;
double height_inch = 0.0;
double height_meter = 0.0;
double weight_pound = 0.0;
double weight_kilo = 0.0;
double BMI = 0.0; cout << "Enter your height in foot and inch" << endl;
cout << "First enter the foot: ";
cin >> height_foot;
cin.get();
cout << "Second enter the inch: ";
cin >> height_inch;
cin.get();
cout << "Enter you weight in pound: ";
cin >> weight_pound;
cin.get();
height_meter = (height_foot * Foot2Inch + height_inch) * Inch2Meter;
weight_kilo = weight_pound / Kilo2Pound; BMI = weight_kilo / (height_meter * height_meter); cout << "Your BIM is " << BMI << endl;
cin.get();
return ;
}

运行结果:  

  Enter your height in foot and inch
  First enter the foot: 12
  Second enter the inch: 45
  Enter you weight in pound: 6
  Your BIM is 0.00118342

3.要求用户以度,分,秒的方式输入一个纬度,然后最终以度为单位显示该纬度。

#include<iostream>
using namespace std;
int main()
{
double degress = 0.0;
double minutes = 0.0;
double seconds = 0.0; cout << "Enter a latitude in degrees,minutes,and seconds:" << endl;
cout << "First enter the the degress: ";
cin >> degress;
cin.get();
cout << "Second enter the minutes: ";
cin >> minutes;
cin.get();
cout << "Finally ,enter the seconds : ";
cin >> seconds;
cin.get(); double last = seconds / / + minutes / + degress; cout << degress << " degress, " << minutes << " minutes, " << seconds << " seconds = " << last << " degrees" << endl;
cin.get();
return ;
}

运行结果:

  Enter a latitude in degrees,minutes,and seconds:
  First enter the the degress: 37
  Second enter the minutes: 51
  Finally ,enter the seconds : 19
  37 degress, 51 minutes, 19 seconds = 37.8553 degrees、

4. 要求用户以整数方式输入秒数,然后以天、小时、分钟和秒的方式显示这段时间。

#include<iostream>
using namespace std;
int main()
{
long total = 0.0;
cout << "请输入秒数,我给您以天、小时、分钟和秒的方式显示这段时间: " ;
cin >> total;
cin.get(); int days;
int hours = ;
int minutes = ;
int seconds = ; days = total / ( * * );
hours = ((total % ( * * )) / ( * ));
minutes = ((total % ( * )) / );
seconds = (total % ); cout << "该段时间为:" << days << " 天 " << hours << " 小时 " << minutes << " 分钟 " << seconds << " 秒 " << endl;
cin.get();
return ;
}

运行结果:  

  请输入秒数,我给您以天、小时、分钟和秒的方式显示这段时间: 4556652
  该段时间为:52 天 17 小时 44 分钟 12 秒

最新文章

  1. 日常总结——JSP篇(补)
  2. Python基础篇【第2篇】: Python自定义函数
  3. iOS 蓝牙开发之传输图片
  4. 2015 年最棒的 5 个 HTML5 框架
  5. Ruby on Rails Tutorial 第一章 之 Heroku部署
  6. JavaScript网站设计实践(四)编写about.html页面,利用JavaScript和DOM,选择性的显示和隐藏DIV元素
  7. 学习笔记-[Maven实战]-第二章:Maven安装和配置
  8. 【CSS】Intermediate5:Specificity
  9. HDFS集群balance(2)-- 架构概览
  10. 织梦DEDECMS网站首页如何实现分页翻页
  11. POJ 1061 青蛙的约会(欧几里得扩展)
  12. Struts1.x 环境搭建和技术准备(上)
  13. reversing.kr easy crack 之write up
  14. css设置黑体宋体等(转)
  15. YII2框架下使用PHPExcel导出柱状图
  16. Linux查看CPU、内存、进程使用情况(转)
  17. jq监听input-val变化事件
  18. jsp的四个作用域page、request、session、application
  19. MySQL【Delete误操作】数据恢复【转】
  20. poj3630 Phone List

热门文章

  1. flexpager权限控制文件crossdomain.xml
  2. DevExpress控件扩展之表达式编辑器
  3. libmysqlclient.so.16未找到方法
  4. php 编译安装指导
  5. 新人学习微信小程序开发之框架篇
  6. 08、Spark常用RDD变换
  7. winform datagridview 如何设置datagridview隔行变色
  8. 调用外部EXE文件
  9. Kubernetes解决了Docker使用中的哪些问题?
  10. javaweb基础(37)_mysql数据库自动生成主键