您的位置:首页 > 编程语言 > C语言/C++

C++ primer plus 第六版课后作业和题——第三章第二题

2018-03-08 16:24 513 查看
/*编写一个小程序,要求用户以度、分、秒的方式输入一个维度,然后以度为单位显示该纬度,
1度为60分,1分等于60秒,请以符号常量的方式表示这些值,对于每个输入值,应使用一个独立的变量
存储它,下面是该程序运行时的情况
输入一个度、分、秒:
首先,输入度:37
再, 输入分:51
最后,输入秒:19
37度,51分,19秒 = 37.8553 度*/

#include <iostream>
using namespace std;

int main()
{
int degrees;
int minute;
int second;
cout << "输入一个度、分、秒:" << endl;
cout << "首先,输入度:" ;
cin >> degrees;
cout << "再, 输入分:" ;
cin >> minute;
cout << "最后,输入秒:" ;
cin >> second;

float sum;
int const n = 60;
sum = degrees + (float) minute/60 + (float) second/60/60;

cout << degrees << " degrees, " << minute << " minute, " << second << " second = " 
<< sum <<endl;

system("pause");
return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: