Enterprise Shell Programming basic problem solving practice

Source: Internet
Author: User

1. Use the shell or Python to write a square (oldboy4.sh) to receive the number entered by the user.
For example: with the + number implementation

[Email protected]:~/script$ vim Oldboy_squarel.SH[email protected]:~/script$./oldboy_squarel.SHPlease Enter a number:4++++++++++++++++++++++++++++++++[email protected]:~/script$CatOldboy_squarel.SH#/biin/Bashread-P"Please Enter a number:"Num for((i=0;i< $num; i++)){     for((j=0;j< $num *2; j + +))    {        Echo-N"+"    }    Echo}

2. Write a isosceles triangle (oldboy2_triangle.sh) in shell or Python to receive the number entered by the user.
Example: Using the * number to achieve

[Email protected]:~/script$ vim Oldboy2_triangle.SH[email protected]:~/script$./oldboy2_triangle.SHPlease Enter the num:3*  *** *****[email protected]:~/script$./oldboy2_triangle.SHPlease Enter the num:5*    ***   *****  ******* *********[email protected]:~/script$CatOldboy2_triangle.SH#/bin/Bashread-P"Please Enter the num:"Num for((i=0;i< $num; i++)){     for((j=0;j< $num-$i; j + +))    {            Echo-N" "    }         for((k=0;k< $i *2+1; k++))    {        Echo-N"*"    }    Echo}

Original problem Source: http://oldboy.blog.51cto.com/2561410/1718607

Enterprise Shell Programming basic problem solving practice

Related Article

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.