这个作业什么时候要呢?
Private Sub Command1_Click()Dim n As Integer
Dim sum As Double
sum = 0
n = InputBox("请输入n的值")
For i = 1 To n
sum = sum + jiecheng(i)
Next i
Print sum
End Sub
Public Function jiecheng(ByVal n As Integer) As Double
Dim jc As Double
jc = 1
For i = 1 To n
jc = jc * i
Next
jiecheng = jc
End Function
答案如下:create table Teacher
( Tno char(5) primary key,
Tname char(8),
Tsex char(2),
Tbirth int,
Tdept varchar(30)
)
create table Course
( Cno char(3) primary key,
Cname varchar(30),
Cpno char(3),
Ccredit int
)
create table 教师授课表
( Tno char(5),
Cno char(3),
time datetime
)
2)在教师表、课程表和教师授课表上建立主外键约束
alter table 教师授课表
add (foreign key(Tno) references Teacher(Tno),
foreign key(Cno) references Course(Cno))
3)建立约束:教师表中教师年龄介于25至60之间
alter table Teacher
add check(Tbirth>=25 and Tbirth<=60)
4)向学生表插入一条记录20050204,'赵勤','女',20,'国贸系'。
insert into Student
values('20050204','赵勤','女',20,'国贸系')
5)在“课程表”的“课程号”列上创建唯一聚集索引。
create unique clustered index idx_cno on Course(Cno)
6)以“课程号”分组,统计各门课程的平均分数大于80分的行。
select Cno,avg(Grade) from SC
group by Cno
having avg(Grade)>80
7)修改学号为“20050306”的学生信息为:20050206,魏海平,男,企管系。
update Student
set Sno='20050206',Sname='魏海平',Ssex='男',Sdept='企管系'
where Sno='20050306'
8)将学号为“20050304”的学生信息从表中删除。
delete from Student
where Sno='20050304'
9)查询所有任课教师的课程,没有课程的教师对应的课程为空。
select Tname,Cname from Teacher
left outer join 教师授课表 on Teacher.Tno=教师授课表.Tno
left outer join Course on 教师授课表.Cno=Course.Cno
10)按课程分组查询计算机学院课程的最低分、最高分和平均分。
select Cno,min(Grade),max(Grade),avg(Grade)
from SC,Student
where SC.Sno=Student.Sno
group by Cno
having Sdept='计算机学院'
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)