Problem description FJ recently opened a mathematical analysis course for his cows. FJ knows that to learn this course well, there must be a good basic function of trigonometric function. So he is going to play a "Sine Dance" game with the cows to improve their computing power.
You may wish to set
An = sin (1-sin (2 + sin (3-sin (4 +... sin (n ))...)
Sn = (... (A1 + n) A2 + N-1) A3 +... + 2) An + 1
FJ wants the cows to calculate the Sn value. Please help FJ print the complete Sn expression to help the cows solve the problem easily. The input format is N <201. In the output format, output the corresponding expression Sn, ending with a line break. No extra spaces, line breaks, or carriage returns are allowed in the output. Sample input 3 sample output (sin (1) + 3) sin (1-sin (2) + 2) sin (1-sin (2 + sin (3) + 1
import java.util.Scanner;public class Main{/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubScanner scanner=new Scanner(System.in);System.out.println(s(Integer.parseInt(scanner.nextLine()), 1));//System.out.print(sin(3, 1));}static String s(int n,int i){if(i==n){return ""+An(n)+"+"+(n-i+1);}else {return "("+An(i)+"+"+(n-i+1)+")"+""+s(n, i+1)+"";}}static String An(int n){return sin(n, 1);}static String sin(int n,int i){if(i==n){return "sin("+n+")";}else {if(i%2==0)return "sin("+i+"+"+sin(n, i+1)+")";//(int)Math.pow(-1,i)else {return "sin("+i+"-"+sin(n, i+1)+")";}}}}