zoukankan      html  css  js  c++  java
  • 使用whIle循环语句和变量打印九九乘法表

    -设置i变量
    declare @i int
    --设置j变量
    declare @j int
    --设置乘法表变量
    declare @chengfabiao varchar(1000)
    --给i,j,@chengfabiao赋初始值
    select @i=9,@j=1,@chengfabiao=''
    --使用whIle循环语句和变量打印九九乘法表
    while @i>=1
    begin
    set @j=@i
    while @j>=1
    begin
    select @chengfabiao=convert(char(2),@j)+'x '+convert(char(2),@i)+'= '+convert(char(2),@i*@j)+' '+@chengfabiao
    set @j=@j-1
    end
    set @chengfabiao=char(10)+@chengfabiao
    set @i=@i-1
    end
    print @chengfabiao

  • 相关阅读:
    Ugly Numbers
    Present
    Out of Hay
    Stars(树状数组或线段树)
    Humble Numbers
    Wireless Network
    Rank List
    Argus
    食物链
    Antenna Placement
  • 原文地址:https://www.cnblogs.com/wlx520/p/4684447.html
Copyright © 2011-2022 走看看