Guess the random number 0-9

Source: Internet
Author: User

Echo "Let's guess the random number 0-9. You have three chances"
Count = 2
N = $ (random % 10 ))
While (count> = 0 ))
Do
Read-P "Please input:" Num
If ($ n = $ num ))
Then
Echo "Congratulation! The random number is $ n. You guessed $ (3-$ count) times in total"
Exit
Elif (n <num ))
Then
If ($ COUNT = 0 ))
Then
Echo-n "high"
Else
Echo "high, there are $ count opportunities"
Fi
Else
If ($ COUNT = 0 ))
Then
Echo-n "low"
Else
Echo "low, there are $ count opportunities"
Fi
Fi
(Count --))
Done
Echo "Unfortunately, you guessed it three times and you have no chance"
Echo "random number is $ N"


This article from the "Love armed for a lifetime" blog, please be sure to keep this source http://menglinux.blog.51cto.com/8733806/1439172

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.