package com.example.demo.jiecheng.controller;
import com.example.demo.th32.model.th32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class JC {
Logger log = LoggerFactory.getLogger(JC.class);
@Autowired
@RequestMapping("/jc")
public static String jc(String[] args) {
int sum = 1;
int i = 1;
int w = 0;
while (sum <= sum * i) {
sum = sum * i;
w = i;
i++;
}
long a = 1;
long w1 = 0;
long b = 1;
while (a <= a * b) {
a = a * b;
w1 = b;
b++;
}
short c = 1;
short w2 = 0;
short d = 1;
while (c <= (short) (c * d)) {
c = (short) (c * d);
w2 = d;
d++;
}
byte e = 1;
byte f = 1;
byte w3 = 0;
while (e <= (byte) (e * f)) {
e = (byte) (e * f);
w3 = f;
f++;
}
int n4 = 1;
int sum4 = 1;
int w4 = 0;
for (char i4 = 1; i4 < n4 + 1; i4++) {
sum4 = sum4 * i4;
if (sum4 > 0 && sum4 <= Character.MAX_VALUE) {
w4 = i4;
n4++;
}
}
double n5 = 1.0;
double sum5 = 1.0;
double w5 = 0;
double s = 0;
for (double i5 = 1; i5 < n5 + 1; i5++) {
sum5 = sum5 * i5;
if (sum5 > 0 && sum5 <= Double.MAX_VALUE) {
s = sum5;
w5 = i5;
n5++;
}
}
float n6 = 1.0f;
float sum6 = 1.0f;
float w6 = 0;
float s1 = 0f;
for (float i6 = 1; i6 < n6 + 1; i6++) {
sum6 = sum6 * i6;
if (sum6 > 0 && sum6 <= Float.MAX_VALUE) {
s1 = sum6;
w6 = i6;
n6++;
}
}
return ("int阶乘最大"+w+"的阶乘"+sum) +";"+
("long阶乘最大"+w1+"的阶乘"+a)+";"+
("short阶乘最大"+d+"的阶乘"+c)+";"+
("byte阶乘最大"+f+"的阶乘"+e)+";"+
("char阶乘为"+w4+"最大值"+sum4)+";"+
("double阶乘为"+w5+"最大值"+s)+";"+
("float阶乘为"+w6+"最大值"+s1);
}
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史