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