1 条题解

  • 0
    @ 2024-12-24 9:54:36

    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

    信息

    ID
    1378
    时间
    1000ms
    内存
    32MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者