PROGRAM LOOPING BINTANG DI SHELL LINUX

7/28/2011 To Live, To Travel 0 Comments


Program pertama :

#!/bin/sh

for((i=1;i<=4;i=$i+1))

do

for((b=1;b<=i;b=$b+1))

do

echo -n "*"

done

echo ""

done







program ke 2 :



For (( i=1 ; i<=4 ; i=$i+1 ))
do
for (( b=1 ; b<=i ; b=$b+1 ))
do
echo -n "$b"
done
echo ""
done



program ke 3:

#!/bin/sh

for ((i=4;i>0;i=$i-1))

do

for ((b=1;b<=i;b=$b+1))
do

echo -n "*"

done

echo ""

done




program ke 4 :

#!/bin/sh

for ((i=1;i<=4;i=$i+1))

do

for ((b=4;b>=i;b=$b-1))

do

echo -n "$b"

done

echo ""

done


program ke 5 :

#!/bin/sh 
# latihan 
for (( i=1; i<=4; i++)) 
do 
for(( k=4; k>=i; k--)) 
do 
echo -n "*" 
done 
echo "" 
done

program ke 6 :

#!/bin/sh
# latihan
for (( i=1; i<=4; i++))
do
for(( k=4; k>=i; k--))
do
echo -n "$k"
done 
echo ""
done



program ke 7:

#!/bin/bash
# Segitiga Piramid

# 0 *
# 1 ***
# 2 *****
# 3 *******
# 4 *********
# 5 ***********
# 6 *************
# . ***************
# . *****************
# . *******************
# n-1 *********************
# ---\/--- | ---\/---
# n - 1 n - 1
#

clear
n=$1
echo -e "\033[47m" #used for colourizing output
for ((row=1;row<=n;row++)) 
do
spaces=$((n-row))
stars=$((2*$row - 1))
for ((i=1;i<=spaces;i++))
do
echo -n ' '
done 
for ((i=1;i<=stars;i++))
do 
echo -e '\033[43m*\033[47m\c'
done
for ((i=1;i<=spaces;i++))
do 
echo -n ' ' 
done
echo
done
echo -e "\033[0m"






Selamat mencoba :))

0 komentar: