[ create a new paste ] login | about

Link: http://codepad.org/HD6jX0YY    [ raw code | output | fork ]

C++, pasted on Sep 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <cmath>
#include <iostream>

using namespace std;
const double PI=3.14159;//常數宣告

double degrees_to_radian(double deg)
{
    return deg * PI / 180.0;
}

int main()
{
    cout << "sin(45.0) = " << sin(degrees_to_radian(45)) << endl;
    cout << "cos(45.0) = " << cos(degrees_to_radian(45)) << endl;
}


Output:
1
2
sin(45.0) = 0.707106
cos(45.0) = 0.707107


Create a new paste based on this one


Comments: