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;
}
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;
}
相关文章推荐
- C++ primer plus 第六版课后作业和题——第二章第七题
- C++ primer plus 第六版课后作业和题——第四章——关于字符串、结构体、共同体、枚举的知识
- C++ primer plus 第六版课后作业和题——第三章第一题
- C++primer plus第六版课后编程题答案 7.8a
- C++primer plus第六版课后编程题答案8.4(补)
- C++primer plus第六版课后编程题答案10.6
- C++primer plus第六版课后编程练习答案2.4
- C++primer plus第六版课后编程练习答案3.4
- C++primer plus第六版课后编程练习答案9.4
- C++primer plus第六版课后编程题答案11.3
- C++primer plus第六版课后编程练习答案12.5与12.6
- C++ primer plus第六版课后编程练习答案:7.3
- C++primer plus第六版课后编程题答案13.1
- C++primer plus第六版课后编程题答案13.4
- C++primer plus第六版课后编程题答案15.1
- C++primer plus第六版课后编程题答案16.6
- C++primer plus第六版课后编程题答案 6.3
- C++ primer plus第六版课后编程练习答案:6.6
- C++ Primer Plus 第六版(中文版)课后编程题----第七章
- C++primer plus第六版课后编程题答案 7.8a