1 solutions
-
0
C :
#include<stdio.h> #include<math.h> int main(){ int n,i; double a,b,s; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%lf %lf",&a,&b); s=a-b; s=s*3.1415926/180; s=sin(s); printf("%.2lf\n",s); } return 0; }C++ :
#include <iostream> #include <math.h> #include <cstdio> using namespace std; const double pi = acos(-1.0); class angle { int X; public: double xsin(); angle() {}; angle(int x) { X=x; } angle operator- (angle c); }; angle angle::operator- (angle c) { return angle(X-c.X); } double angle::xsin() { double x=X*pi/180; return sin(x); } int main() { //freopen("test.in", "r", stdin); //freopen("test.out", "w", stdout); int p, q, t; scanf("%d", &t); while (t--) { scanf("%d %d", &p, &q); angle a(p),b(q),d; d=a-b; printf("%.2f\n", d.xsin()); } return 0; }Java :
import java.text.DecimalFormat; import java.util.Scanner; public class Main { private static Scanner s = new Scanner (System.in) ; static DecimalFormat df = new DecimalFormat("0.00") ; public static void main(String[] args) { int n = s.nextInt() ; for (int i = 0; i < n; i++) { int x = s.nextInt() ; int y = s.nextInt() ; System.out.println(df.format(Math.sin(Math.PI*((double)(x-y)/180)))); } } }
- 1
Information
- ID
- 19778
- Time
- 1000ms
- Memory
- 32MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By