KLIK

Shell Programming

4.5

echo -n "Batas Angka : ";
read n;
gj=1;
gn=2;
echo -n "Ganjil : ";
while [ $gj -le $n ];
do
echo -n "$gj, ";
let gj=$gj+2;
done
echo "";
echo -n "Genap : ";
while [ $gn -le $n ];
do
echo -n "$gn, ";
let gn=$gn+2;
done
echo "";




echo -n "Masukkan Batas : "
read batas;
f1=1;
f2=0;
for (( i=0; i<$batas; i++ ))
do
let fibo[$i]=$f1+f2;
f1=$f2
f2=fibo[$i]
done
for (( i=0; i<$batas; i++ ))
do
for (( j=0; j<=$i; j++ ))
do
printf "${fibo[$j]} "
done
printf "\n"
done





menu=0;
i=0;

input(){
let i=$i+1
echo -n "Masukkan A : "
read a[$i]
echo -n "Masukkan B : "
read b[$i]
echo -n "Masukkan C : "
read c[$i]

let h1=3*${b[$i]}
let h2=${a[$i]}+$h1
let h3=2*${c[$i]}
let h4=$h3+${a[$i]}
let h5[$i]=h2+h4
}

view(){
echo "Data $x"
echo ""
echo "Hasil = ${h5[$x]}"
echo ""
}

cek(){
echo -n "Masukkan Data yang dicari : "
read cari;

for (( x=1; x<=i; x++ ))
do

if [ ${a[$x]} = ${a[$cari]} ] && [ $cari != $x ]
then
echo "Nilai A ke $x = Nilai A ke $cari"
echo " ${a[$x]} = ${a[$cari]}"
fi
if [ ${b[$x]} = ${b[$cari]} ] && [ $cari != $x ]
then
echo "Nilai B ke $x = Nilai B ke $cari"
echo " ${b[$x]} = ${b[$cari]}"
fi
if [ ${c[$x]} = ${c[$cari]} ] && [ $cari != $x ]
then
echo "Nilai C ke $x = Nilai C ke $cari"
echo " ${c[$x]} = ${c[$cari]}"
fi
done
}


for (( menu=0; menu!=4; ))
do
echo "1. Input | 2. View | 3. Cari | 4. Exit"
echo -n "Menu : "
read menu;

case $menu in
1) input; ;;
2) for (( x=1; x<=i; x++ ))
do
view;
done;;
3) cek; ;;
4) echo "Exit";;
*) echo "Ulangi";;
esac
done


Klik jika artikel ini bermanfaat
UBLO SEVEN

Post Author : M. Arief Ubaidillah

Terimakasih atas kunjungan dan kesediaan anda membaca artikel ini. Kritik dan Saran dapat anda sampaikan melalui Kotak Komentar di bawah ini atau di Facebook (Muhammad Arief Ubaidillah) bisa juga di Twitter (@ubeeed).

0 comments:

Komentar Anda Sangat Bermanfaat

Silahkan Berkomentar !

 
The Official Website Of Arief Ubaidillah
Copyright© 2013 UBLO SEVEN™ | Use Chrome To The Maximum Result