#define pi 3.14159 (2207)#include <bits/stdc++.h> using namespace std; class angle{ public: int x; angle(int xx):x(xx){ } void operator-(const angle& a){ cout<<fixed<<setprecision(2)<<sin((x-a.x)*pi/180)<<endl; } }; int main(){ int m,x1,x2; cin>>m; while(m--){ cin>>x1>>x2; angle a(x1); angle b(x2); a-b; } return 0; }
#include<iostream> #include<algorithm> #include<iomanip> using namespace std; class angle { public: int n; angle operator -(angle a) { this->n -= a.n; return *this; } void cal() { cout << fixed << setprecision(2) << sin((double)n / 180 * 3.1415926) << endl; } }; int main() { int m; cin >> m; for (int i = 0; i<m; i++) { angle a, b, temp; cin >> a.n >> b.n; temp = a - b; temp.cal(); } }
#include <iostream> #include <string> #include <algorithm> #include <cmath> #include <iomanip> using namespace std; class angle{ public: double angles; angle operator - (const angle &b){ this->angles=this->angles-b.angles; return *this; } }; int main() { int n; cin>>n; while(n>0){ angle a,b; cin>>a.angles>>b.angles; cout<< fixed << setprecision(2)<<sin((a.angles-b.angles)*3.141592653/180)<<endl; n=n-1; } return 0; }
import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int m = in.nextInt(); for (int i = 0; i < m; i++) { int angle1 = in.nextInt(); int angle2 = in.nextInt(); double result = Math.sin(angle1 * Math.PI / 180 - angle2 * Math.PI / 180); System.out.println(String.format("%.2f", result)); } } } }
#include<iostream> #include<cmath> using namespace std; class angle { public: double n; angle operator -(angle a) { this->n -= a.n; return *this; } void caculate() { printf("%.2lf",sin(n / 180 * M_PI));//将角度转化为弧度再运用sin求解 cout << endl; } }; int main(void) { int m; while(cin >> m) { while(m--) { angle x,y,z; cin >> x.n >> y.n; z = x - y; z.caculate(); } } return 0; }
#include <stdio.h> #include <stdlib.h> #include <math.h> #define PI acos(-1) int main() { int m; while(~scanf("%d", &m)) { for(int i = 0; i < m; i++) { int alpha, beta; scanf("%d%d", &alpha, &beta); double sinx = sin((alpha - beta) * PI / 180.0); printf("%.2lf\n", sinx); } } return 0; }C语言里没有重载一说,也没有类。。
#include<iostream> #include<stdio.h> #include<math.h> using namespace std; class angle { public: double degree; angle() { degree = 0; } angle(double d) { this->degree = d; } angle operator -(const angle other) { angle result; result.degree = degree - other.degree; return result; } void show() { double t = sin(this->degree*3.1415926 / 180); printf("%.2lf\n", t); } }; int main() { int m; angle a, b, c; cin >> m; while (m) { cin >> a.degree >> b.degree; c = a - b; c.show(); m--; } }
#include<stdio.h> #include<math.h> #define PI 3.1415926 int main() { int m; while (!scanf("%d",&m)) { while(getchar()!='\n') continue; } int i; double angle1=0,angle2; for (i=0;i<m;i++) { scanf("%lf %lf",&angle1,&angle2);//double类型格式化输入要用%lf printf("%.2f\n",sin((angle1-angle2)/180.0*PI)); } return 0; }
#include <iostream> #include <iomanip> #include <cmath> const double PI = acos(-1); using namespace std; class Angle { public: double degree; Angle(double de){degree=de;} Angle(){} Angle operator-(const Angle& a){ Angle a1; a1.degree=degree-a.degree; return a1; } }; int main(){ int m; double d1,d2,result; cin>>m; for(int i=0;i<m;i++){ cin>>d1>>d2; Angle angle1(d1),angle2(d2),angle0=angle1-angle2; result=sin(angle0.degree*PI/180); cout<<fixed<<setprecision(2)<<result<<endl; } return 0; }
最后别忘了把浮点数转化为与π相关的数哦 #include<iostream> #include<cmath> #include<iomanip> const double PI = 3.1415925; using namespace std; class Angle{ public: Angle() : angle_(0) {} Angle(double a0) : angle_(a0) {} friend Angle operator -(const Angle&, const Angle&); double angle_; }; Angle operator -(const Angle& a1, const Angle& a2) { return Angle(a1.angle_ - a2.angle_); } int main() { int m; cin>>m; while(m-- > 0) { double a1, a2; cin>>a1>>a2; Angle ang1(a1), ang2(a2), ang3; ang3 = ang1 - ang2; cout<<setiosflags(ios::fixed)<<setprecision(2)<<sin(ang3.angle_ / 180.0 * PI)<<endl; } return 0; }
#include<stdio.h> #include<math.h> const double PI = acos(-1); class Angle { public: int a; Angle(int num) { this->a = num; } Angle operator-(Angle b) { return Angle(a - b.a); } void printSin() { printf("%.2f\n", sin((this->a) / 180.0 * PI)); } }; int main() { int m, a, b; scanf("%d", &m); for (int i = 0; i < m; i++) { scanf("%d%d", &a, &b); Angle a1(a), a2(b), a3(0); a3 = a1 - a2; a3.printSin(); } return 0; }
/* https://zhidao.baidu.com/question/223161864 LWQ */ #include <stdio.h> #include <math.h> using namespace std; #define PI 3.1415926 int main() { int m; while (scanf("%d", &m) != EOF) { float a, b; for (int i = 0; i < m; i++) { scanf("%f%f", &a, &b); printf("%.2f\n", sin((a - b)*PI / 180)); } } return 0; }
#include <iostream>
#include <cmath>
#include <cstdio>
#define PI 3.1415926535
using namespace std;
class Angle
{
public:
float n;
Angle operator -(Angle b)
{
Angle a;
a.n = this->n - b.n;
return a;
}
void cal(void)
{
printf("%.2f\n", sin(n*PI/180));
}
};
int main()
{
int m,i;
cin >> m;
for(i=0;i<m;i++)
{
Angle a,b,tmp;
cin >> a.n >> b.n;
tmp = a-b;
tmp.cal();
}
return 0;
}
import math
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner s = new Scanner(System.in); int n = s.nextInt(); while(n-- > 0){ int a = s.nextInt(); int b = s.nextInt(); System.out.println(String.format("%.2f", Math.sin((a-b)*Math.PI/180))); } } }