当前位置: 代码迷 >> 综合 >> ZZULIOJ 1053: 正弦函数,Java
  详细解决方案

ZZULIOJ 1053: 正弦函数,Java

热度:24   发布时间:2023-11-25 08:54:20.0

1053: 正弦函数

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    Scanner cin = new Scanner(System.in);double middle,result;double x=cin.nextDouble();result=0;for(double i=1;i<=10;i++){
    middle=Math.pow(x,2*i-1)/molecule(2*i-1);if(i%2==1) result+=middle;else result-=middle;}System.out.printf("%.3f",result);}public static Double molecule(double n){
    double res=1;for(double i=1;i<=n;i++)res*=i;return res;}
}
  相关解决方案