--1.乘法表左上declare @a int,@b int,@c varchar(max)set @a=1set @c=''while @a<=9beginset @b=1 while @b<=(10-@a) begin set @c=@c+cast(@a as varchar(1))+'*'+ cast(@b as varchar(1)) +'='+left(cast(@a*@b as varchar(2))+' ',3) set @b=@b+1 endprint @cset @c=''set @a=@a+1end--2.乘法表左下declare @a int,@c varchar(max)set @a=1set @c=''while @a<=9beginset @b=1 while @b<=@a begin set @c=@c+cast(@a as varchar(1))+'*'+ cast(@b as varchar(1)) +'='+left(cast(@a*@b as varchar(2))+' ',3) set @b=@b+1 endprint @cset @c=''set @a=@a+1end--3.乘法表右上declare @a int,@c varchar(max)set @a=1set @c=''while @a<=9beginset @b=1 while @b<=9 begin if @a>@b set @c=@c+' ' else set @c=@c+cast(@a as varchar(1))+'*'+ cast(@b as varchar(1)) +'='+left(cast(@a*@b as varchar(2))+' ',3) set @b=@b+1 endprint @cset @c=''set @a=@a+1end--4.乘法表右下declare @a int,@c varchar(max)set @a=1set @c=''while @a<=9beginset @b=1 while @b<=9 begin if (@a+@b)<10 set @c=@c+' ' else set @c=@c+cast(@a as varchar(1))+'*'+ cast(@b as varchar(1)) +'='+left(cast(@a*@b as varchar(2))+' ',3) set @b=@b+1 endprint @cset @c=''set @a=@a+1end--5.乘法表菱形内空declare @a int,@c varchar(max)set @a=1set @c=''while @a<=9beginset @b=1 while @b<=9 begin if @a<=5 and @b>(5-@a) and @b<(5+@a) set @c=@c+' ' else if @a>5 and @b>(@a-5) and @b<(15-@a) set @c=@c+' ' else set @c=@c+cast(@a as varchar(1))+'*'+ cast(@b as varchar(1)) +'='+left(cast(@a*@b as varchar(2))+' ',3) set @b=@b+1 endprint @cset @c=''set @a=@a+1end--6.乘法表菱形外空declare @a int,@c varchar(max)set @a=1set @c=''while @a<=9beginset @b=1 while @b<=9 begin if @a<=5 and (@b<=(5-@a) or @b>=(5+@a)) set @c=@c+' ' else if @a>5 and (@b<=(@a-5) or @b>=(15-@a)) set @c=@c+' ' else set @c=@c+cast(@a as varchar(1))+'*'+ cast(@b as varchar(1)) +'='+left(cast(@a*@b as varchar(2))+' ',3) set @b=@b+1 endprint @cset @c=''set @a=@a+1end总结
以上是内存溢出为你收集整理的sqlserver实现各种乘法表全部内容,希望文章能够帮你解决sqlserver实现各种乘法表所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)