c++ 度分秒相互转化
生活随笔
收集整理的這篇文章主要介紹了
c++ 度分秒相互转化
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
c++ 度分秒相互轉化
源代碼如下:
#include "stdafx.h" #include <iostream> using namespace std;void show(double degree) {int D = degree;int F;int E;F = (degree - D) * 60;E = ((degree - D) * 60 - F) * 60;cout << "轉化成度分秒為:" << endl;cout << D << "度" << F << "分" << E << "秒" << endl; //度轉化成度分秒 }double f1(double degree, int minute,int second) //度分秒轉化成秒 {double x;x = degree * 3600 + minute * 60 + second;return x; }double f2(double degree) //度轉化成秒 {double z;z = degree * 3600;return z; }int _tmain(int argc, _TCHAR* argv[]) {cout << "請輸入一個度:" << endl;double degree;cin >> degree;show(degree);int minute, second;cout << "請輸入一個度分秒:" << endl;cin >> degree >> minute >> second;cout << "轉化成秒為:" << f1(degree, minute, second) << endl;cout << "請輸入一個度:" << endl;cin >> degree;cout << "轉化成秒為:" << f2(degree);return 0; }測試運行結果如下:
總結
以上是生活随笔為你收集整理的c++ 度分秒相互转化的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab教程蚁群算法,蚁群算法怎样用
- 下一篇: C++离航篇——函数默认参数、函数重载、