package org.example;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
System.out.println("Nechta raqam kiritmoqchisiz funksiyaga: ");
int n= scanner.nextInt();
int[] f=new int[n];
double sum=0;
double[] C=new double[n];
for (int i = 0; i < n; i++) {
System.out.println("f["+i+"]= ");
f[i]=scanner.nextInt();
}
for (int i = 0; i < n; i++) {
sum+=f[i];
}
System.out.println(sum);
for (int i = 0; i < n; i++) {
if (i==0){
C[i]=Math.sqrt((double) 1 /n)*sum*Math.cos((double) (2 * i + 1) /(2*n))*i*3.14;
}else {
C[i]=Math.sqrt((double) 2 /n)*sum*Math.cos((double) (2 * i + 1) /(2*n))*i*3.14;
}
System.out.println("The result is : "+ C[i]);
}
}
}
Dostları ilə paylaş: |