zoukankan      html  css  js  c++  java
  • 大年三十。让字母在屏幕上奔跑:(sleep , system"clear")

    system "clear",ruby清屏(osk系统上,window上用system "cls")。

    https://stackoverflow.com/questions/116593/how-do-you-clear-the-irb-console/116614 

    sleep 1 #程序等待1秒。 

    让字母在屏幕上奔跑:

    用到嵌套循环:

    1.外循环用于输出奔跑步数(配合system "clear"和sleep 0.1出现奔跑效果)

    2.内循环用于输出在字母H前面打印多少个空格,print " "(体现奔跑的效果)

    i = 0
    while i <= 100
      system "clear"
      b= 1 #第一次内循环判断flase,不打印空格
      while b <= i
        print " "
        b += 1
      end
      print "H "
      sleep 0.2
      i += 1
    end

    从右往左跑的小人:

    增加头身腿,三行。每行都要有空格的循环配合。 

    i = 1
    while i <= 20
      system "clear"
      b= 21
      while b >= i
        print " "
        b -= 1
      end
      print " O "
      b = 21
      while b >= i
        print " "
        b -= 1
      end
      print "<H> "
      b = 21
      while b >= i
        print " "
        b -= 1
      end
      print "I I"
      sleep 0.05
      i += 1
    end
  • 相关阅读:
    SSM中shiro的基本使用
    TortoiseGit小乌龟 git管理工具
    vux用法
    vue webpack打包
    vue2.0 watch
    vue2.0 $emit $on组件通信
    简单工具 & 杂技
    html基础问题总结
    Node应用进程管理器pm2的使用
    node express 登录拦截器 request接口请求
  • 原文地址:https://www.cnblogs.com/chentianwei/p/8449302.html
Copyright © 2011-2022 走看看