
CodeCursor 和vscode联合编程,AI编程测试
1 安装CodeCursor。2 启动CodeCursor。插入一个求阶乘的函数。
·
1 安装CodeCursor
2 启动CodeCursor
3 AI写代码
测试完全正确
插入一个求阶乘的函数
测试完全正确
import java.util.Scanner;
public class JavaRun {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the first number: ");
int num1 = input.nextInt();
System.out.print("Enter the second number: ");
int num2 = input.nextInt();
int sum = num1 + num2;
sum = factorial(sum);
System.out.println("The sum of " + num1 + " and " + num2 + " is " + sum);
input.close();
}
public static int factorial(int n) {
if (n == 0) {
return 1;
} else {
return n * factorial(n - 1);
}
}
}
更多推荐
所有评论(0)