import java.util.Scanner;
public class CalculateZ {
public static void main(String args[]){
int x = 0;
int y = 0;
int n;
Scanner stdin = new Scanner(System.in);
System.out.println("input five num");
int i = 5;
while(i != 0){
int t = stdin.nextInt();
x = x+t;
i--;
}
System.out.println("x = "+x);//输出前5个数字和
System.out.println("input five num");
int j = 5;
while(j != 0){
int t = stdin.nextInt();
y = y+t;
j--;
}
System.out.println("y = "+y);//输出后5个数字和
System.out.println("input n:");
n = stdin.nextInt();
double z = fun(x, y, n);
System.out.printf("%.2f", z);// 输出z
}
static double fun(int x,int y,int n){
double xx = 1;
double yy = 1;
long ns = 1l;
while(n != 0){
xx = xx*x;
yy = yy*y;
ns = ns*n;
n--;
}
// System.out.println("xx = " +xx);
// System.out.println("yy = " +yy);
System.out.println("n! = " +ns);//输出n的阶乘
return Math.sqrt((xx + yy)/ns);
}
}
|