**#### ay13 2023/03/13
难度:简单
题目1
现有若干个学生(不超过100的数据记景,每个记录包括学号姓名,三科成绩,学号不超过15位,且有字母。成绩为整数,每名学生的姓名不超过10个字母,且只包含字母,读入条记录,再按要求输出
- 输入:学生数量n占一行每个学生的学号、姓名、三科成绩占一行,空格分开。
- 输出:每个学生的学号、姓名、三科成绩占一行,逗号分开。
题目2
求和s=1!+2!+3!++10!(阶乘求和)
示例
输入:1
c666 zxl 100 100 100
输出:c666,zxl,100,100,100
说明:1代表1个学生数据,其他输入依次为学号,姓名,成绩1,2,3,在按要求输出
思路:直接在构造函数里输出相应的值就行
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
student student[] = new student[N];
for (int i = 0;i < student.length;i++){
student[i] = new student(sc.next(),sc.next(), sc.nextInt(), sc.nextInt(),sc.nextInt());
}
System.out.println(jiecheng(5));
}
```
class student{
String No;
String name;
int math;
int chinese;
int English;
public student(String no, String name, int math, int chinese, int english) {
No = no;
this.name = name;
this.math = math;
this.chinese = chinese;
English = english;
System.out.println(no+" "+name+" "+math+" "+chinese+" "+english);
}
}
```
题目二:
思路:利用递归实现阶乘;
static int jiecheng(int n){
if (n == 1)return 1;
n *= jiecheng(n-1);
return n;
}
- 时间复杂度 O(1) ---所占用时间仅常数级
- 空间复杂度 O(1)--- 仅常数级变量,无额外的辅助空间