(MYSQL)编写存储过程,实现求一元二次方程的根(假设该方程有实数根)。多谢
发布网友
发布时间:2022-05-16 03:01
我来回答
共1个回答
热心网友
时间:2023-10-09 13:55
曾经写过一个,你看看,你最好弄个实际需求,也好帮你
已知(a*7+b*9+c*10+d*5+222)%11=3 ,a,b,c,d都是0-9的整数,怎么用sql输出a,b,c,d的所有结果
declare @a int
declare @b int
declare @c int
declare @d int
declare @str int
set @str=0
while @str<=9999
begin
set @a=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),1,1) as int)
set @b=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),2,1) as int)
set @c=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),3,1) as int)
set @d=cast(substring(right('0000'+cast(cast(@str as varchar) as varchar),4),4,1) as int)
if (@a*7+@b*9+@c*10+@d*5+222)%11=3
begin
print ('a='+cast(@a as varchar)+' b='+cast(@b as varchar)+' c='+cast(@c as varchar)+' d='+cast(@d as varchar))
end
set @str=@str+1
end
sqlserver中直接运行即可,mysql的你也就照着改一下吧