日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ruby推送示例_Ruby直到示例循环

發布時間:2025/3/11 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ruby推送示例_Ruby直到示例循环 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ruby推送示例

直到循環 (The until loop)

The until loop is one of the great features of Ruby which makes it different from other programming languages. The support of until loop specifies how much user-friendly language Ruby is?

直到循環是Ruby的重要功能之一,這使其與其他編程語言有所不同。 對直到循環的支持指定了Ruby用戶友好語言是多少?

The until loop is just the opposite of while loop if we justify it in terms of functionality. while loop is executed as long as the Boolean condition stands to be false but in case of until loop, it executes as long as the Boolean condition does not come out to be true. It is the example of the entry-control loop where the specified condition is checked prior to the execution of the loop's body.

如果我們從功能上證明它,則直到循環與while循環正好相反。 while循環是只要布爾條件成立的情況是假的,但直到循環的情況下執行,因為布爾條件不出來是真實的它執行長。 這是進入控制循環的示例,其中在執行循環主體之前檢查指定的條件。

The until loop is implemented with the help of the following syntax:

使用以下語法可以實現直到循環 :

until conditional [do]# code to be executedend

Example 1:

范例1:

=begin Ruby program to print a message 10 times using until loop =endnum=0until num==10puts "Hello there! Message from Includehelp.com! Happy learning!"num=num+1 end

Output

輸出量

Hello there! Message from Includehelp.com! Happy learning! Hello there! Message from Includehelp.com! Happy learning! Hello there! Message from Includehelp.com! Happy learning! Hello there! Message from Includehelp.com! Happy learning! Hello there! Message from Includehelp.com! Happy learning! Hello there! Message from Includehelp.com! Happy learning! Hello there! Message from Includehelp.com! Happy learning! Hello there! Message from Includehelp.com! Happy learning! Hello there! Message from Includehelp.com! Happy learning! Hello there! Message from Includehelp.com! Happy learning!

Example 2:

范例2:

=begin Ruby program to find the sum of all digits of given number using until loop =endputs "Enter the number" num=gets.chomp.to_itemp=num sum = 0until num==0#implementation of until looprem=num%10num=num/10sum=sum+rem endputs "The sum of #{temp} is #{sum}"

Output

輸出量

Enter the number 456672 The sum of 456672 is 30

Example 3:

范例3:

=begin Ruby program to find the count of even and odd digits in the given number using until loop =endputs "Enter the number" num=gets.chomp.to_itemp=num evecount=0 oddcount=0until num==0#implementation of until looprem=num%10num=num/10if rem%2==0puts "#{rem} is even"evecount+=1elseputs "#{rem} is odd"oddcount+=1end endputs "Number of even numbers are #{evecount}" puts "Number of odd numbers are #{oddcount}"

Output

輸出量

Enter the number 7896532 2 is even 3 is odd 5 is odd 6 is even 9 is odd 8 is even 7 is odd Number of even numbers are 3 Number of odd numbers are 4

翻譯自: https://www.includehelp.com/ruby/until-loop.aspx

ruby推送示例

總結

以上是生活随笔為你收集整理的ruby推送示例_Ruby直到示例循环的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。